Re: storing related structs




"Grey Alien" <grey@xxxxxxxxxxxxx> ha scritto nel messaggio news:ifOdnb3U0drIyBvbnZ2dnUVZ8qSnnZ2d@xxxxxxxxx


Army1987 wrote:

<snip></snip>
struct C {
unsigned id;
char name; /* do you mean *name, or name[LARGE_ENOUGH]? */
enum { strA, strB } type;
Why have you declared an enum here? ^ (can't see why this is needed)

The point is, you have to somehow keep track of wheter the union
contains a struct A or a struct B.


union {
struct A str_A;
struct B str_B;
} the_struct;
};



.



Relevant Pages