Why the output is 8 bytes instead of 6 bytes??


9/3/2019 10:33:11 AM

Noor ❤

8 Answers

New Answer


Need not be. if struct elements are not aligned to it's memory, then only padding will be done. In 32 bit system, struct size shall be 32 bit aligned. Padding improves performance.


2 bytes have been padded, resulting in 8 bytes. 4 bytes int + 2 bytes char + 2 padding bytes...


see this Noor ❤ https://www.sololearn.com/post/78037/?ref=app


✳AsterisK✳ I got it now. Thanks for making the things easy to understand


i think ~ swim ~ have explained this before, the structure padding works in blocks of 4 or something i can't remember clearly cause am also struggling in this context


✳AsterisK✳ Yes it's structure padding at work. You have found a good link (Babak's one) go through it and let me know if you need explanation for anything.


Use so: https://code.sololearn.com/cDUtFj1Ra4jv/?ref=app


Kuri do structure reserves 2 bytes for padding?