Union in C by R4R Team

Union:
A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time.

Syntax-
Union name
{
data types;
};

Differnce between structure and union:
Example
struct name
{
int a;
char ch;
};

union name1
{
int a;
char ch;
}

sizeof(name): 5
sizeof(name1): 4

Hence total size of union is equal to the size of biggest data type define in it.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!