I'm using the Code::Blocks IDE with the GNU GCC compiler.
struct test
{
char a;
char e;
char f;
char b;
char d;
};
sizeof(test)
returns 5
.
I read this answer: Why isn't sizeof for a struct equal to the sum of sizeof of each member?
How come there is no padding after the last char
, so that sizeof(test)
returns 6
or 8
? There are a ton more questions I could ask once I add short
and int
, etc. But I think this question is good for now. Would not padding make it easier for the processor to work with the struct?