liveBook · Manning

Calloc

calloc is a C standard-library function that allocates contiguous storage for an array of elements and initializes all allocated bytes to zero.

How 2 Manning books explain it

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.

Read how Modern C, Third Edition explains calloc →

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.

Read how Modern C explains calloc →

Related concepts

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.