Calloc
calloc is a C standard-library function that allocates contiguous storage for an array of elements and initializes all allocated bytes to zero.
Modern C, Third Edition
calloc is a C standard-library function that allocates storage for an array of elements and initializes all allocated bytes to zero.
- How it is used
- Allocates dynamically sized arrays while clearing their newly allocated storage.
- How deep it goes
- Defines the interface and bit-clearing behavior, then limits use to positive sizes and representations where zero bits initialize the type validly.
- Examples
- Uses an integer-array allocation example and contrasts calloc with assignment-based initialization for other object types.
- What you can do after
- Apply it via <stdlib.h> to obtain cleared storage for suitable dynamically allocated arrays and release that storage afterward.
Modern C
calloc is a C standard library function that allocates storage for an array of elements and initializes all allocated bits to zero.
- How it is used
- Allocates dynamically sized array storage whose allocated bits begin at zero.
- How deep it goes
- Defines calloc as a malloc specialization and relates it to void* storage, but does not develop implementation details.
- Examples
- Uses a large vector allocation and a platform-size feasibility exercise to contextualize dynamically allocated storage.
- What you can do after
- Apply it via stdlib.h when dynamically allocated storage should begin with all allocated bits cleared.
Related concepts
- mallocalternative to · malloc is a C standard-library function that allocates a specified number of bytes of uninitialized storage and returns a pointer to it or a null pointer if allocation fails.
- freeused by · free is a C standard-library function that releases dynamically allocated storage previously obtained from a compatible allocation function.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

