ProgrammingVery hard

struct T { int a; double d; }; printf("%d", (int)(sizeof(struct T) == 16)); What is printed with 4-byte int and 8-byte double (natural alignment)?

  1. A. 0
  2. B. 12
  3. C. 8
  4. D. 1

Correct answer: D. 1

a takes 4 bytes, then 4 bytes of padding align d to 8, which takes 8 bytes, for a total of 16.

More C Programming questions

Exams that ask this topic