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

Answer Posted / clay

Here,

After char *p;
since pointer p is not initialized it is pointing at some
unknown location.

In the next step, the address of the memory allocated by
malloc() is stored at some garbage location pointed by p.

Here p is never initialized or never assigned any value.

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I sort more data than will fit in memory?

630


What is %d called in c?

761


Linked lists -- can you tell me how to check whether a linked list is circular?

646


What are register variables? What are the advantage of using register variables?

687


Is flag a keyword in c?

682






What is s in c?

618


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

1600


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14964


what are the facialities provided by you after the selection of the student.

1658


Difference between macros and inline functions? Can a function be forced as inline?

712


How can I invoke another program or command and trap its output?

617


a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above

873


Apart from dennis ritchie who the other person who contributed in design of c language.

813


What is a union?

611


pierrot's divisor program using c or c++ code

1732