ProgrammingModerate

With a 4-byte int and an 8-byte pointer, natural alignment, what is sizeof(struct N) for struct N { int v; struct N *next; };?

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

Correct answer: B. 16

v takes 4 bytes, then 4 bytes of padding align the pointer, which takes 8 bytes. The total is 16.

More C Programming questions

Exams that ask this topic