Question 1Medium
calloc() returns a storage that is initialized to.
- Zero
- Null
- Nothing
- One
Answer: A. Zero
Explanation
calloc() sets every byte of the block it allocates to zero, so the storage starts as zero. malloc() does not do this.
Step-by-step solution
- Calloc allocates memory for a number of elements and sets every byte to zero.
- So the memory it returns starts zero-filled.
- The answer is Zero, which is option A.
Why the other options are wrong
- B. Null is returned only when allocation fails, not as the initial value.
- C. Nothing is not a value; calloc fills the memory with zeros.
- D. One is wrong because the bytes are cleared to zero.
Tip: Calloc zeroes memory; malloc does not.