Call Us : +91-8376986802 (Viber, WhatsApp)

What is Union in C-Language?



Unions are like structures, in which the individual data types may differ from each other. All the members of the union share the same memory / storage area in the memory. Every member has unique storage area in structures. In this context, unions are utilized to observe the memory space. When all the values need not assign at a time to all members, unions are efficient. Unions are declared by using the keyword union , just like structures.

Ex: union item {
int code;
float price;
};

The members of the unions are referred as – book1.title, book1.author, book1.pages, book1.price.

Leave a Reply