Discussion
Which of the following statement is correct prototype of the malloc() function in c ?
Answer: D
Correct answer: void* malloc(size_t);
The prototype takes a size_t - an unsigned type large enough to hold the size of any object - and returns void *.
Both halves matter. The void * return is what allows one function to serve every type, and size_t rather than int is what allows allocations larger than an int can express on a 64-bit machine. It also means a negative size argument is converted to a very large positive one, so the allocation simply fails rather than misbehaving.
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