What's wrong with "char *p; *p = malloc(10);"?

Answer Posted / shruti

the syntax of malloc is wrong.

in your example it should be written as:

char *p;

p = (char *)malloc(sizeof(char));

Is This Answer Correct ?    21 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is output redirection?

670


What is the c value paradox and how is it explained?

578


How can you read a directory in a C program?

655


Explain do array subscripts always start with zero?

763


What are the Advantages of using macro

688






How can you increase the allowable number of simultaneously open files?

599


How can you invoke another program from within a C program?

620


What are the disadvantages of c language?

624


What is difference between class and structure?

573


Is c compiled or interpreted?

670


pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)

1865


What are the different types of data structures in c?

610


Which is better between malloc and calloc?

673


What do you mean by invalid pointer arithmetic?

637


What are all different types of pointers in c?

581