

#include <stdlib.h> void *calloc(size_t n, size_t size);
calloc allocates a block of dynamic memory to contain n
elements of the size specified by size. The block is cleared to
binary 0s before return.
calloc returns the address of the first character of the new block
of memory. The allocated block is suitably aligned for storage of any
type of data.
NULL is returned.
n * size.
Under an XA or ESA operating system, memory allocated by calloc
can reside above the 16-megabyte line for programs that run in 31-bit
addressing mode.
See malloc for further implementation information.
#include <stdio.h>
#include <stdlib.h>
double *identity(int size) {
double *matrix;
int i;
matrix = calloc(sizeof(double), size*size);
if (matrix == NULL) return(NULL);
for (i = 0; i < size; ++i)
matrix[size*i + i] = 1.0;
return matrix;
}
malloc
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.