Share this page

# union

Allows the grouping of common variables together. Unions work in the same way as structures except that all variables are contained in the same location in memory. Enough space is allocated for the largest variable in the union. All variables in the union share the same memory location. See also struct.

## Example

In the following example, a union, mixed,contains just one of either the character, radian, or number fields. Two instances of the union, a and b, are then used in the function Actions.

        union mixed {
            char character;
            float radian;
            int number;
        }

        union mixed a, b;
        a.number = 7;
        b.character = 'e';
        lr_output_message ("number value is %d", a.number);
        lr_output_message ("character value is %c", b.character);

    Example: Output:
    Action.c(14): number value is 7
    Action.c(15): character value is e

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: