C Programming/Unions Datatype

From Chorke Wiki
Revision as of 06:14, 5 February 2018 by Shahed (talk | contribs) (Created page with "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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
};