分类: C/C++
2011-03-30 21:36:57
calloc(m, n) is essentially equivalent to + |
There is
no important difference between the two other than the number of arguments and
the zero fill.
Malloc:
Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
Calloc:
Allocate space for array in memory
Allocate a block of memory for an arrray of num element, each of them size bytes long, and initialized all its bits to zero.
The effective result is the allocation of an zero-initialized memory block of (num*size) bytes.