allocate space for an array
#include <stdlib.h> /* For ANSI compatibility (calloc only) */ #include <malloc.h> /* Required for other function prototypes */ void *calloc ( size_t n, size_t size ); void __based (void) *_bcalloc ( __segment seg, size_t n, size_t size ); void __far *_fcalloc ( size_t n, size_t size ); void __near *_ncalloc ( size_t n, size_t size );
The calloc() functions allocate space for an array of n objects, each of length size bytes. Each element is initialized to 0.
Each function allocates memory from a particular heap, as listed below:
In a small data memory model, the calloc() function is equivalent to the _ncalloc() function; in a large data memory model, the calloc() function is equivalent to the _fcalloc() function.
The calloc() functions return a pointer to the start of the allocated memory. The return value is NULL (_NULLOFF for _bcalloc()) if there is insufficient memory available or if the value of the size argument is zero.
_expand, free, halloc(), hfree(), malloc, _msize, realloc, sbrk()
#include <stdlib.h> void main() { char *buffer; buffer = (char *)calloc( 80, sizeof(char) ); }