Go to the first, previous, next, last section, table of contents.


calloc

Syntax

#include <stdlib.h>

void *calloc(size_t num_elements, size_t size);

Description

This function allocates enough memory for num_elements objects of size size. The memory returned is initialized to all zeros. The pointer returned should later be passed to free (see section free) so that the memory can be returned to the heap.

You may use cfree (see section xfree) to free the pointer also; it just calls free.

Return Value

A pointer to the memory, or NULL if no more memory is available.

Portability

ANSI, POSIX

Example

Complex *x = calloc(12, sizeof(Complex));
cfree(x);


Go to the first, previous, next, last section, table of contents.