What is union?

Union

The concept of the union is same like the structure the difference is of their storage method. All the data-members of the union are share same storage area. Union is very useful where we don’t want to assign the values to all the data members at same time.

e.g:      union employee

{

int id;

char name[20];

float salary;

}emp;

And access of the union data-members is same like the structure.

e.g:      emp.id;

Leave a Reply

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