I know the differences between union and structure. But from a design and coding perspective what are the various use cases of using a union instead of a structure? One is a
Ins some cases we may have to use only one variable at a time but the different results will have to be stored with different names. In such cases union will help by allocating same space for each variable at one location with the maximum variable size.
i.e if we use int and char then union will allocate space for char which has the bigger size and the int too 'll be stored in the same space overriding the last one.