difference between calloc() and malloc() mcq - mallocとcallocの違いは?

what is correct about malloc() function / c / malloc / calloc

することの違いは何でしょうか。

ptr = (char **) malloc (MAXELEMS * sizeof(char *));
ptr = (char **) calloc (MAXELEMS, sizeof(char*));

Mat



Answer #1
size_t count = get_int32(file);
struct foo *bar = malloc(count * sizeof *bar);
size_t count = get_int32(file);
struct foo *bar = calloc(count, sizeof *bar);