0
723views
What is a Union ?
1 Answer
0
1views

Like structures, a union can be declared using the keyword union as follows:

union item 
{
int m; 
float x; 
char c; 
} code;

This declares a variable code of type union item. The compiler allocates a piece of storage that is large enough to hold the largest variable type in the union.

To access a union member, we can use the same syntax that we use for structure members. That is,

code.m 
code.x 
code.c
Please log in to add an answer.