What is structure padding? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What is structure padding?

I heard about the term structure padding related to memory of members... is it same like int and char are two members... then both would consider 4 and 4 bytes instead of 4 and 1 byte...?

22nd Jun 2019, 3:34 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Answers
+ 8
If you are transferring binary data between servers that are written in different languages, this is another instance of when you need to be aware of automatic padding.
22nd Jun 2019, 5:05 AM
Sonic
Sonic - avatar
+ 4
~ swim ~ I guess you have given example.... but is it int , char and float causing problem....? because char is having three bytes left which cannot accomodate next float... does this mean that if only two members were present like int and char, would it result into 5 bytes only...? or else does it mean that order of data member int,float , char would result into 9 bytes only...? or in any case padding would happen at all...?
23rd Jun 2019, 5:56 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
23rd Jun 2019, 7:43 AM
Ketan Lalcheta
Ketan Lalcheta - avatar