Unions In C

A union is a special data type in C that allows to store different data types in the same memory location. 

Unions are similar to structures. The syntax of union is also similar to that of structure. The only difference is in storage. In structure each member has its own storage location, whereas all members of union use a single shared memory location which is equal to the size of its largest data member.

 We can access only one member of union at a time. We can‟t access all member values at the same time in union. But, structure can access all member values at the same time. This is because, Union allocates one common storage space for all its members. Where as Structure allocates storage space for all its members separately .

Example 

union employee 

{
int emp_id; 

char name[20]; 

int salary; 

};