How to initialize a structure variable B or C?
typedef struct _A { union { struct { int b; } B; struct { int c; } C; } u; } A;
Something A.u.B *bVar;doesn't seem to work
A.u.B *bVar;
You have to put your structure aside.
typedef struct { int b; } B;
typedefcovers only A, not the association or structures defined in it.
typedef
A
typedefcannot be nested this way: each user-defined "type" must have one label, so declaring a type variable A.u.Bis illegal.
A.u.B
:
/* Initialise to zero */ A a = {{{0},{0}}}; /* Now set the b to 5 */ a.u.B.b = 5;
, , . , A, A.u, A.u.B, 0 A.u.B.b. A.u.B, , A.u.C, A.u.C.c, .
A.u
0
A.u.B.b
A.u.C
A.u.C.c
. . , ...