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

Discussion

Specify the 2 library functions to dynamically allocate memory?

  • A.malloc() and memalloc()
  • B.alloc() and memalloc()
  • C.malloc() and calloc()
  • D.memalloc() and faralloc()

Answer: C

Correct answer: malloc() and calloc()

malloc and calloc are the two allocation functions in standard C. malloc takes a single total size and leaves the block uninitialised; calloc takes a count and an element size and zeroes the result.

The standard library also provides realloc to resize an existing block and free to release one, so four functions in all - but only two of them allocate fresh storage. The others named in the options are not standard C at all.

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

Post your comment

Please log in or register to post a comment.