The basic data types here refer to simple built-in data types such as short, int, long, float and double, because they are all related to the system.
Therefore, the values under different systems may be different, which must arouse our attention and try not to bring trouble to the transplantation of our own programs in this respect. Typically, in a 32-bit compilation environment, the value of sizeof(int) is 4.
Extended data:
Look at the result of sizeof(S2) and see how it is still 8. Then look at the memory. There are three padding bytes after the original member C. Why? Don't worry, let's summarize the rules.
The details of byte alignment are related to the compiler implementation, but generally speaking, three criteria must be met:
The first address of the 1) structure variable can be divisible by the size of its widest basic type member;
2) The offset of each member of the structure relative to the first address of the structure is an integer multiple of the size of the member, and the compiler will add internal padding); If necessary, between members;
3) The total size of the structure is an integer multiple of the size of the widest basic type member of the structure. If necessary, the compiler will add trailing padding after the last member.