Union Structures

Union declarations are of the form:

union [union_name]
type element_name;
type element_name;
type element_name;
} [var_name, var_name] ;

where the optional var_names are variables declared to be of this union type, and the optional union_name is a name for this union type which may be used in subsequent variable declarations of the form:

union union_name var_name;

Each element in the union variable is defined at the same memory address, so that they all overlap. The number of bytes reserved for the union variable is the number of bytes required for the largest element. Apart from this, the union variable is used in exactly the same way as a structure variable.