Machine-translated by Google. Questions are authored in English.
Top

Discussion

Memory returned by malloc() is automatically initialised to zero.

  • A.True
  • B.False

Answer: B

Correct answer: False

malloc() leaves the contents of the block indeterminate, so reading it before writing is undefined behaviour. calloc() is the function that clears the memory to zero, and it is the reason calloc() is preferred when a zeroed buffer is required.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.