[prev] 76 [next]

Unions

A union is a special data type available in C that allows storing different data types in the same memory location.

The size of a union is equal to the size of its largest member (plus any padding).

An example of declaring a union

union MyUnion {
    unsigned long long value;
    char   s[8];
};

This union can store either an unsigned long long value, or a string of size 8 (including the '\0' terminator).