ProgrammingHardWipro · Cognizant pattern

Assume a 64-bit LP64 ABI and 1-byte Bool. What is printed?

Assume a 64-bit LP64 ABI and 1-byte _Bool. What is printed?
struct S { _Bool b; double d; };
printf("%zu", sizeof(struct S));
  1. A. 9
  2. B. 16
  3. C. 12
  4. D. 8

Correct answer: B. 16

b@0 (1 byte); d needs 8-byte alignment so it is pushed to offset 8 (7 padding bytes), occupying 8-15; end 16 is already a multiple of 8.

More C Programming questions

Exams that ask this topic