What is the difference between doing:
ptr = (char **) malloc (MAXELEMS * sizeof(char *));
or:
ptr = (char **) calloc (MAXEL
Both malloc
and calloc
allocate memory, but calloc
initialises all the bits to zero whereas malloc
doesn't.
Calloc could be said to be equivalent to malloc + memset
with 0 (where memset sets the specified bits of memory to zero).
So if initialization to zero is not necessary, then using malloc could be faster.