banner

Union

                          
    A "union declaration" specifies a set of variable values and, optionally, a tag naming the union. The variable values are called "members" of the union and can have different types. Unions are similar to "variant records" in other languages.


Example:-

union sign   /* A definition and a declaration */
{
    int svar;
      char 1[20];
} number;


union time
{
int i;
char a;
}my;

#include<stdio.h>
int main()
{
my.i=6;                                  ../using union variable
my.a='A';
}

Note:-The size of the structure is sum of the size of each member in the struchture.but size of the union is size
of Largest member in the union because union members are overlaps on each other in memory.
If we declare two structure variables,Both variables are stored in different location
but union stored in same location.