Where do you get 20? I get 14, 4 per int, 2 per short, 1 per char.
Anyway, about padding:
http://vcfaq.mvps.org/lang/11.htm
In particular:
Quote:
the compiler pads the end of the structure with dummy bytes until the structure size is a multiple of the largest alignment in the structure. That way the alignment for all consecutive structures is valid.
|
Your largest type is 4 bytes, so the struct is padded up to the nearest multiple of 4, which is 16. This behavior can be modified with the pragma described in the above link.
Each compiler will likely be different, but it sounds like yours is doing something similar to this.