Name
calloc function — Allocates memory
Synopsis
void* calloc(size_t count, size_t size)
The calloc
function
allocates count
elements, each of
size
bytes, and initializes the
allocated memory to all zeros. It returns a pointer to the start of
the newly allocated memory or a null pointer if there is
insufficient memory to fulfill the request. The pointer is suitably
aligned for any type.
C++ programs should use the new
operator instead of calling calloc
. Call fill
or memset
to fill the allocated memory with
zeros.
See Also
free function, malloc function, realloc function, new
keyword, fill
in <algorithm>
, memset
in <cstring>
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.