Discussion
Among 4 header files, which should be included to use the memory allocation functions like malloc(), calloc(), realloc() and free()?
Answer: B
Correct answer: #include<stdlib.h>
stdlib.h declares malloc, calloc, realloc and free. It is the only header of those offered that is required.
string.h declares memset and strcpy, which are often used alongside allocation but are not part of it. memory.h is a non-standard header on some systems and should not be relied upon. Omitting stdlib.h is particularly dangerous because an older compiler will assume malloc returns int and truncate the address.
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