void * malloc(size_t n) returns:
Answer: D
Correct answer: Both a & b are true
Both statements describe malloc correctly. On success it returns a pointer to n bytes of uninitialised storage - the contents are whatever the allocator hands over, which is the difference from calloc.
On failure it returns NULL, and that is its only means of reporting failure. Checking the return value is therefore the caller's responsibility, and neglecting it is a common fault: the program dereferences a null pointer and crashes some distance from the real cause.
Please log in or register to report this question.