ProgrammingVery hard

A struct {int a; char b;} is used in an array of 3 elements on a platform with 4-byte int and natural alignment. What is sizeof(arr)?

  1. A. 15
  2. B. 12
  3. C. 9
  4. D. 24

Correct answer: D. 24

Each element is padded to 8 bytes because of the 4-byte alignment, so 3 x 8 = 24.

More C Programming questions

Exams that ask this topic