What is printed by this C code: int m = {{1, 2, 3}, {4, 5, 6}}; printf(“%d”, *(*(m + 1) + 1));?
Correct answer A. 5
Explanation
m + 1 points to the second row {4, 5, 6} because m decays to a pointer to an array of 3 ints. Dereferencing gives that row, which decays to a pointer to its first element, and adding 1 moves to the second element, 5. So *(*(m + 1) + 1) is the same as m[1][1]. Answer 2 confuses the row step with a single int step.
Answer checked How we write and check questions
Discussion