What is the use of calloc() function?
Calloc() function is used to initialize memory. Calloc() function is used to allocates a group of object.
Syntax of allocating Calloc() function are given below:
void *calloc(size_t number, size_t size);
size_t-> is a synonym for unsigned.
number-> is the num of object to allocate.
size-> It shows the size of each object in bytes.
When memory allocation with calloc() function is successful,than function returns a pointer.
Otherwise,it returns 0.
printf("Enter the num(int)to allocate: ");
pointer = (int*)calloc(number, sizeof(int));
if (pointer != NULL)
puts("successful Memory allocation .");
puts(" failed Memory allocation.");