How does calloc differ from malloc?
-
A
calloc leaves the block uninitialised
-
B
calloc zero-fills the allocated block
Correct answer
-
C
calloc places the block on the stack
-
D
calloc resizes an existing block
Correct answer
B. calloc zero-fills the allocated block
13 views
Explanation
calloc allocates and sets every byte to zero, whereas malloc leaves the memory uninitialised.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ