Consider struct alignment rules as described below –
- Each primitive data (int, char, float, etc.) type requiring $\text{K}$ bytes must be stored at the address must be multiple of $\text{K}.$
- Address of structure and structure length must be multiples of $\text{K}_{\max}.$ Where $\text{K}_{\max}$ is the largest size of any primitive element of the struct.
The sizes are as follows -
sizeof (long int)=8 bytes
sizeof (int)=4 byte
sizeof (short int)=2 bytes
struct s{
short int a [5];
long int b;
}
What will be $\text{sizeof(struct s)}?$
- $24$
- $18$
- $32$
- $20$