c++ - struct size not as expected when using bit fields -


with below code:

struct s { unsigned char b1 : 3; int i; }; 

i can deduce char b1 of 1 byte , using 3 bits of , int 4 bytes when try print out size of s, 8 bytes instead of 5 bytes(1 char+4 int) expected , not understanding obvious. can explain why size of s 8 bytes?


Comments

Popular posts from this blog

c++ - list<myClass<int> * > sort -

How to populate a bash array with a file's lines -

java - Unity Ads Android Integration - Reloading Video Ad issue -