Difference between malloc and calloc?

What is the difference between doing: ptr = malloc (MAXELEMS * sizeof(char *)); or: ptr = calloc (MAXELEMS, sizeof(char*)); When is it a good idea to use calloc over malloc or vice versa? 14 s 14 calloc() gives you a zero-initialized buffer, while malloc() leaves the memory uninitialized. For large allocations, most calloc implementations under … Read more