Accessing the members of an union

Individual union members can be used in the same way as the structure members, by using the member operator or dot operator (.).

However, there is an important difference in accessing the union members. Only one union member should be accessed at a time. Because a union stores its members on top of each other, it’s important to access only one member at a time. Trying to access the previously stored values will result in erroneous output.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: