ProgrammingHardProduct company OA

Assume a 64-bit LP64 ABI (8-byte long long, natural alignment). What is printed?

Assume a 64-bit LP64 ABI (8-byte long long, natural alignment). What is printed?
struct LL { char a; long long b; char c; };
printf("%zu", sizeof(struct LL));
  1. A. 16
  2. B. 17
  3. C. 9
  4. D. 24

Correct answer: D. 24

a@0, 7 bytes of padding so b (8-byte aligned) sits at offset 8, ending at 16; c@16, then 7 bytes of trailing padding to round the struct up to a multiple of 8 (long long's alignment): 24 total.

More C Programming questions

Exams that ask this topic