Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why does sizeof report a larger size than I expect for a structure type, as if there was padding at the end?

0
10 Posted

Why does sizeof report a larger size than I expect for a structure type, as if there was padding at the end?

0
10

Structures may have this padding (as well as internal padding; see also question 9.5), so that alignment properties will be preserved when an array of contiguous structures is allocated. 9.10: My compiler is leaving holes in structures, which is wasting space and preventing “binary” I/O to external data files. Can I turn off the padding, or otherwise control the alignment of structs? A: Your compiler may provide an extension to give you this control (perhaps a #pragma), but there is no standard method. See also question 17.2.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123