ProgrammingHard

struct P { char a; int b; }; printf("%zu", offsetof(struct P, b)); What is printed with 4-byte int and natural alignment (stddef.h included)?

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

Correct answer: B. 4

The int must start at a multiple of 4, and the char a occupies offset 0, so b starts at offset 4.

More C Programming questions

Exams that ask this topic