Discussion
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.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development