Home / Questions / What is the difference between malloc() and calloc()?
Explanatory Question

What is the difference between malloc() and calloc()?

👁 878 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Issues  calloc() malloc()
Description The malloc() function allocates a single block of requested memory. The calloc() function allocates multiple blocks of requested memory.
Initialization It initializes the content of the memory to zero. It does not initialize the content of memory, so it carries the garbage value.
Number of arguments It consists of two arguments. It consists of only one argument.
Return value It returns a pointer pointing to the allocated memory. It returns a pointer pointing to the allocated memory.