size of struct in C [duplicate]
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof of each member? Consider the following C code: #include <stdio.h> struct employee { int id; char name[30]; }; int main() { struct employee e1; printf("%d %d %d", sizeof(e1.id), sizeof(e1.name), sizeof(e1)); return(0); } The output is: 4 30 36 Why is the size of the structure not equal to the sum of the sizes of its individual component variables? 回答1: The