C Programming/Unions Datatype

From Chorke Wiki
Jump to navigation Jump to search

Unions are declared in the same fashion as structs, but have a fundamental difference. Only one item within the union can be used at any time, because the memory allocated for each item inside the union is in a shared memory location.

union Shape {
    int circle;
    int triangle;
    int oval;
};