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

Is there a way to compare two structure variables?

839


Explain what are global variables and explain how do you declare them?

834


What do mean by network ?

880


What is an expression?

836


What does it mean when a pointer is used in an if statement?

851


How to create struct variables?

807


write a program to concatenation the string using switch case?

1794


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

813


What is mean by data types in c?

752


Explain how do you search data in a data file using random access method?

902


In C language what is a 'dangling pointer'?

831


Explain how many levels deep can include files be nested?

824


What is the difference between strcpy() and memcpy() function in c programming?

844


What is 02d in c?

834


What is the use of c language in real life?

767