ProgrammingHardWipro · Cognizant pattern

Assume a 64-bit LP64 ABI. What is printed?

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

Correct answer: B. 16

data@0 (4 bytes), then 4 bytes of padding so the 8-byte-aligned pointer next can start at offset 8, next@8 (8 bytes): total 16, already a multiple of 8 (the struct's strictest alignment, from the pointer).

More C Programming questions

Exams that ask this topic