Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Size of a structure : Structure Padding
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Kislay, post: 3079115"] case 1 : struct s { char c1[6]; // 8 double d; // 8 int i1; // 4 char c2[2]; // 4 int i2; // 4 }; case 2: struct s { char c1[6]; // 8 double d; // 8 int i1; // 4 char c2[2]; // 4 int i2; // 4 float f // 4 }; According to the rules of structure padding shouldn't the size of the above structure be 28 bytes (for a 32 bit compiler , I am using DEV-C+ +) ? But I got 32 as the answer , using sizeof . And when I added "float f" to the structure , I was getting the same answer , 32 . Well , if 32 is right instead of 28 in the first case , then after adding a float , shouldn't it become 36 ? But even in case 2 , its 32 . Is there more to structure padding than simple clubbing together in groups of 4 ? Somebody please shed some light ? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Size of a structure : Structure Padding
Top