Possible Duplicate:
What is the actual size of a struct in C
I wrote the following program in C and I'm a little confused about the size of the struct that the executable prints. Here is the code:
#include <stdio.h>
#include <stdlib.h>
struct domi1{
char x;
int c;
char y;
};
struct domi2{
char x;
char y;
int c;
};
main(){
printf("The size of domi1 is: %d\n", sizeof(struct domi1));
printf("The size of domi2 is: %d\n\n", sizeof(struct domi2));
system("pause");
}
The program prints 12 as the size of domi1 and 8 as the size of domi2. Why is that? I appreciate your help!