Possible Duplicate:
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
#include <stdio.h>
int main(){
struct word1{
char a;
int b;
char c;
};
struct word2{
char a;
char b;
int c;
};
printf("%d\t%d\n", sizeof(int), sizeof(char)); //Output : 4 1
printf("%d\t%d\n", sizeof(struct word1), sizeof(struct word2)); //Output: 12 8
return 0;
}
The code is available at IDEONE.
Why is the size of struct 1 (word1) greater than the size of struct 2 (word2)?
Is this a compiler problem?