ProgrammingHard

struct Pt { int x, y; }; struct Pt pts[3] = {{1, 2}, {3, 4}, {5, 6}}; struct Pt *p = pts + 1; printf("%d %d", p->x, (p - pts)); What is printed?

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

Correct answer: D. 3 1

p points at the second element, so p->x is 3, and the difference of the two pointers is the index 1.

More C Programming questions

Exams that ask this topic