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

how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1674


What is meant by errors and debugging?

841


regarding pointers concept

1795


What is the use of f in c?

730


What is switch in c?

835


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3252


Is using exit() the same as using return?

909


What is a ternary operator in c?

843


Why static variable is used in c?

749


how to execute a program using if else condition and the output should enter number and the number is odd only...

1915


Compare and contrast compilers from interpreters.

889


Explain how can a program be made to print the name of a source file where an error occurs?

927


Who developed c language and when?

815


What are loops in c?

758


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

1133