What is the difference between a struct and a union?

A union is like a struct in that it generally has several fields, all of which are public by default. Unlike a struct, however, only one of the fields is used at any given time. In other words, it is a structure that allows the same storage space to be used to store values of different data types at different times.

Sizin İçin Seçtik  Why do we use union inside structures in C?

Leave a Reply

Your email address will not be published. Required fields are marked *