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); Where, 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. Example: #include#include main() { unsigned number; int *pointer; printf("Enter the num(int)to allocate: "); scanf("%d", &number); pointer = (int*)calloc(number, sizeof(int)); if (pointer != NULL) puts("successful Memory allocation ."); else puts(" failed Memory allocation."); return(0); }