ProgrammingHardIBM · Deloitte pattern

Assume 64-bit LP64. What is printed?

Assume 64-bit LP64. What is printed?
struct Node {
    int val;
    struct Node *next;
};
printf("%zu", sizeof(struct Node));
  1. A. 8
  2. B. 12
  3. C. 24
  4. D. 16

Correct answer: D. 16

val@0 (4 bytes); next needs 8-byte alignment (pointer size on LP64), so padding fills bytes 4-7, next@8 (8 bytes). Total 16, already a multiple of 8.

More C Programming questions

Exams that ask this topic