Why does sizeof report a larger size than I expect for a structure type, as if there were padding at the end?
Structures may have this padding (as well as internal padding), if necessary, to ensure that alignment properties will be preserved when an array of contiguous structures is allocated. Even when the structure is not part of an array, the end padding remains, so that sizeof can always return a consistent size. See question 2.12.
References:
H&S Sec. 5.6.7 pp. 139-40
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995 // mail feedback