calloc is the C standard library’s “clear allocate” function: it dynamically allocates storage for an array and sets every allocated bit to 0. Like malloc, it returns void* storage that can serve different object types. section 13.1
TAKEAWAY: Use calloc when cleared dynamically allocated storage is suitable.
- calloc belongs to the stdlib.h allocation interface alongside malloc, free, realloc, and aligned_alloc. section 13.1
- Its array-oriented allocation complements malloc’s byte-based storage model, while sizeof helps express the required size from the pointed-to type. section 13.1
- Choosing calloc instead of malloc can avoid a class of problems caused by uninitialized dynamically allocated objects; more complicated structures still need specific initialization. section 15.0
A cleared dynamic array
Suppose a program must create storage for one element per living person. The allocation’s required size depends on the number of elements and the element type; calloc is the specialized choice when the newly allocated bits should begin at zero. A related feasibility exercise asks you to compute the size of a large vector on your platform before attempting the allocation. section 13.1

