ProgrammingHard

struct P { int a[3]; }; struct P p = {{1, 2, 3}}; struct P *q = &p; printf("%d", *(q->a + 2)); What is printed?

  1. A. 3
  2. B. 2
  3. C. 1
  4. D. 0

Correct answer: A. 3

q->a decays to a pointer to the first int, and adding 2 reaches the third element, which is 3.

More C Programming questions

Exams that ask this topic