12 bytes, four bytes for each of three integers.
A
block of memory for this struct consists of twelve bytes.
The first field (age
) is located at a displacement of
zero into the block.
The second field (pay
) is located at a displacement of
four into the block.
The last field (class
) is located at a displacement of
eight into the block.
struct { int age; int pay; int class; };
Warning: C and C++ compilers are free to rearrange the order of items inside a struct and to do other things for optimization or hardware compatibility. Worse yet, different compilers may do different things. Do not write C programs that make assumptions about the internal structure of a struct.