What is union in c ?

What is union in c?

union is a collection of variables under a single name but all variables have same memory location.

Example:

Output : 
20
As we can see from output that if t1.a and t1.b have same value.So union allocates single memory for all variables defined under union.

%d bloggers like this: