*sigh* I love how when this topic clicks, all is well in the universe. If kids learned assembler first nowadays I think perhaps it would be more intuitive.
A char is one byte.
Code:
void function1(void)
{
int c;
char d;
float h;
printf("c is %d bytes\nb is %d bytes\nh is %d bytes\n", sizeof c, sizeof d, sizeof h);
printf("The distance from c to h is %d bytes", (char *)(&h + 1) - (char *)(&c));
}
The problem with data being aligned on weird boundaries is that it makes the stack run less efficiently since it keeps needing to realign the stack to different boundaries.
Code:
void function2(void)
{
struct {
int c;
char d;
float h;
} t;
printf("t.c is %d bytes\nt.b is %d bytes\nt.h is %d bytes\nt is %d bytes\n", sizeof t.c, sizeof t.d, sizeof t.h, sizeof t);
printf("The distance from t.c to t.h is %d bytes", (char *)(&t.h + 1) - (char *)(&t.c));
}
The structure aligns data more efficiently. Its an invisible characteristic that won't effect your code at all. It does become an issue when parsing binary files, however.