ProgrammingModerate

For struct { char name[4]; int v; } with a 4-byte int and natural alignment, what is sizeof of the struct?

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

Correct answer: B. 8

name occupies bytes 0 to 3, which ends at an aligned address, so v starts at offset 4 without padding. The size is 8.

More C Programming questions

Exams that ask this topic