Union
Unions are quite similar to the structures in C. Union is
also a derived type as structure. Union can be defined in same manner as
structures just the keyword used in defining union in union where keyword used
in defining structure was struct.
The major difference between structure and union is that
structure provide separate memory space for each variable but union provided
same memory space to variable particular datatype.
e.g.:
union tag
{
Int a;
Char b;
Double c;
}
Main()
{
Union tag v;
Printf(“%d\n”,sizeof(v));
}
No comments:
Post a Comment