This article is a union example.
A union is a collection of data of the same or of different type having the same or different size. These data are overlaid shairing the same memory location. So , we initialize only one member of the union each time. The size of a union is equal to the size of the largest member.
A union is similar to a structure and all that are true about structures are also true and about unions.
The C code The result
Memory views of the example is here. |