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

Discussion

In the call calloc(n, size), what do the two arguments represent ?

  • A.The total bytes and an alignment value
  • B.The number of elements and the size of each element
  • C.The starting address and the length
  • D.The size in bytes and an initialisation value

Answer: A

Correct answer: The number of elements and the size of each element

calloc() multiplies the two arguments to find the total number of bytes, then clears them. Splitting the request in two lets the library detect an overflow in that multiplication, which a single-argument malloc() call cannot do.

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

Post your comment

Please log in or register to post a comment.