✏️ Explanatory Question

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

👁 878 Views
📘 Detailed Answer
💡

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.