A common padding scheme is to pad structs so that each member starts at an even multiple of the size of that member or to the machine word size (whichever is smaller). The entire struct is padded following the same rule.
Assuming such a padding scheme I would expect:
The biggest member in struct A
has size 1, so no padding is used.
In struct B
, the size of 5 is padded to 8, because one member has size 4.
The layout would be:
int 4
char 1
padding 3
In struct C
, some padding is inserted before the int
, so that it starts at an address divisible by 4.
The layout would be:
char 1
padding 3
int 4