Platform-specific unsigned type for array indices and memory sizes.
1st Parameter
The number of elements to allocate
2nd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
2nd Parameter
The size of each element in bytes
Read more about parameters of calloc in parameters section
The callocfunction in C language dynamicall allocates memory on the heap, initializing allocated bytes to zero.
..
The callocfunction takes 2
parameters:
•
size_t `nmemb`: The number of elements to allocate
•
size_t `size`: The size of each element in bytes
Allocates memory for an array of `nmemb` elements of `size` bytes each, initializing all bits to zero. Returns a pointer to the allocated memory or `NULL` if the allocation fails.
The calloc function return value :
Returns a pointer to the allocated memory if successful, or NULL if the memory allocation fails
Output
This example demonstrates the basic usage of `calloc` to allocate an array of integers. Note that all elements are initialized to zero.