Challenge 2: calloc's Zero-Initialization, Observed Directly — Possible Solution ==================================================================== #include #include int main() { int *nums = calloc(3, sizeof(int)); if (nums == NULL) { return 1; } printf("%d %d %d\n", nums[0], nums[1], nums[2]); free(nums); return 0; } Output: 0 0 0 Explanation: per the chapter, calloc zero-initializes the memory it allocates -- every byte of the requested block is explicitly set to 0 before calloc returns, which for an int array means every element reads as the integer 0, even though nothing was ever written to it directly in this program. Contrast with malloc: malloc(3 * sizeof(int)) would allocate the same AMOUNT of memory, but would NOT zero it -- the bytes would contain whatever leftover values happened to already be sitting in that memory from whatever previously used it. Printing those three ints without writing to them first would show unpredictable, essentially garbage values -- not necessarily 0, and not consistent from one run to the next, since it depends entirely on the memory's prior contents. WHY THIS WORKS AS AN ANSWER ------------------------------ This confirms calloc's output is reliably 0 0 0 -- a guaranteed, deterministic result -- and explicitly contrasts it with malloc's genuinely undefined/garbage contents for the identical allocation size, which is precisely the distinction the chapter calls "genuinely important safety-wise."