Question 86
Assume int is 4 bytes, char is 1 byte, and 4-byte alignment is enforced. What is sizeof(struct S) for:
struct S {
char c1;
int i;
char c2;
};Detailed Solution
c1 takes 1 byte + 3 padding bytes (4). 'i' takes 4 bytes (8). c2 takes 1 byte + 3 trailing padding bytes to round up to multiple of 4, yielding 12 bytes.