One-C union community per dayEvery day, I picked up a C-language shell, which grew up and formed thousands of miles.
Today's shells: Space storage and usage of the C-language union community. Union community usage:Union community name{Data of data type members;Data of data type members;
......};Space storage: All data members in the union community share a piece of memory, and the data written to the Members will overwrite the previous Member data. The member data has the same first address, this is nuion's largest storage feature. The use of memory by union is incredible, but it is used only under special conditions. The size of union is the size of the maximum data member. In the preceding example, Myunion occupies 4 bytes.Determine the system size:
The union member data shares the memory, and the first address is the first byte of the low address. Int I = 1:Large-end storage: 1 is stored at the highest address.Small-end storage: 1 is stored at the lowest address.When reading char ch, it is the first byte of the lowest address. The size-side storage will display different values, so you can easily determine the size of the system.