ProgrammingVery hard

Assume natural alignment: char 1, double 8. What is sizeof(struct T) for struct T { char a; double d; char b[3]; }?

  1. A. 24
  2. B. 19
  3. C. 16
  4. D. 32

Correct answer: A. 24

a is at offset 0, d at offset 8, b at offsets 16 to 18, so 19 bytes are needed. The struct is padded to a multiple of its 8-byte alignment, giving 24.

More C Programming questions

Exams that ask this topic