ProgrammingHard

Which statement about calloc(n, size) is guaranteed by the C standard?

  1. A. The n x size bytes are set to zero, which malloc does not do
  2. B. It returns a block that is uninitialised but zero-sized
  3. C. It can be used with free only if n is 1
  4. D. It zeroes memory only for types that have pointers

Correct answer: A. The n x size bytes are set to zero, which malloc does not do

calloc zero-fills its block and reports overflow of the product by returning NULL. Its arguments are not otherwise limited.

More C Programming questions

Exams that ask this topic