ProgrammingHard

struct P { char a; int b; char c; }; printf("%zu", sizeof(struct P)); What is printed with 4-byte int and natural alignment?

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

Correct answer: A. 12

a sits at 0, b is aligned to offset 4, c is at 8, and the total is padded to the 4-byte alignment, giving 12.

More C Programming questions

Exams that ask this topic