G'day!
Usually if I was using malloc, I'd check for failure via:
int *A;
A=(int *)malloc(NUM_ELEMENTS*sizeof(int));
if (!A) {
printf("mem failure, exiting \n");
exit(EXIT_FAILURE);
}
Can I do the same thing for calloc, even though everything is assigned to 0? My gut feel is yes, because we'd be checking the mem address of A, and it doesn't matter that A[0] is 0, the mem address won't be null unless it failed.