#include <stdio.h>
typedef struct {
char a;
short b;
char c;
int d;
} Test;
int main ()
{
printf("%ld", sizeof(Test));
return 0;
}
Why the ouput is 12 and not 8?
It seems that the compilers add the padding like this : char(1), short(2), padding(1), char(1), padding(3), int(4), so the result is 12, but why it doesn't put char, short, char, int so the result is 8?