malloc(): Allocates requested size of bytes and returns a pointer first byte of allocated space. The contents of allocated memory are not changed. i.e., the memory contains unpredictable or garbage values. This presents a risk.
calloc(): Calculates the size to be allocated and allocates, initializes it to zero and then returns a pointer to memory.
Syntax
void *malloc (size_in_bytes);
void *calloc (number_of_blocks, size_of_each_block_in_bytes);
Example
int * array;
if ( NULL == (array = malloc(10 * sizeof(int))) ) {
printf("malloc failed\n");
return(-1);
}
int * array;
if ( NULL == (array = calloc(10, sizeof(int))) ) {
printf("calloc failed\n");
return(-1);
}