ProgrammingHard

On a machine with 4-byte int, what does sizeof(*r) give when int (*r)[3] is a pointer to a row of three ints?

  1. A. 4
  2. B. 8
  3. C. 12
  4. D. 3

Correct answer: C. 12

r points to an array of three ints, so *r is the whole row of type int[3] and sizeof *r = 3 x 4 = 12. 4 is sizeof **r (one int), and 3 counts the elements rather than the bytes.

More C Programming questions

Exams that ask this topic