Discussion
Why is calloc() function used for?
Answer: B
Correct answer: allocates the specified number of bytes and initializes them to zero
calloc does two things where malloc does one: it allocates the storage and sets every byte of it to zero.
It also takes its size as a count and an element size rather than a single total, and it is required to detect overflow in the product of the two - a check a hand-written malloc(m * n) does not get. Resizing an existing block is realloc's work, described by the third option.
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