size of struct in C [duplicate]

The compiler may add padding for alignment requirements. Note that this applies not only to padding between the fields of a struct, but also may apply to the end of the struct (so that arrays of the structure type will have each element properly aligned). For example: struct foo_t { int x; char c; }; … Read more