/* ex8-356-11.c */ #include #define RECTANGLE 1 #define CIRCLE 0 struct point { int x; int y; }; struct shape { int shape_kind; /* RECTANGLE or CIRCLE */ struct point center; /* coordinate of center */ union { struct { int length; int width; } rectangle; struct { int radius; } circle; } u; } s; main() { s.shape_kind = RECTANGLE; printf("%d\n", s.shape_kind); s.center.x = 10; printf("%d\n", s.center.x); s.u.rectangle.width = 8; printf("%d\n", s.u.rectangle.width ); s.u.circle = 5; printf("%d\n", s.u.circle ); s.u.radius = 5; printf("%d\n", s.u.radius ); return 0; }