calloc function is used to allocate an array in memory with elements initialized to 0.
void * calloc( size_t nElements, size_t nSize )
returns a pointer to the allocated space, or NULL if there is insufficient memory available.
EX1
void calloc_ex1() { int *pn; size_t nNumerOfIntegersToAllocate = 200; pn = (int*)calloc(nNumerOfIntegersToAllocate, sizeof(int)); if (pn != NULL) out_str("Allocation succesful"); else out_str("Allocation failed!"); // free the allocated memory: free(pn); }
malloc
origin.h