What is a Union?

Union is quite similar to structure. Like structure, union is also used to store data of different data types. The only difference between structure and union is that in case of structure different variables are stored in their individual space in memory where as in case of Union total space that is required by the variables in memory is equal to the size of largest data type.
Eg: union student
{
int roll;
char name[10];
float marks;
}
The union student will take 10 bytes in memory that is equal to the size of largest variable.

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.