Re: storing related structs



Gray Alien wrote:
I have two related structs:


struct A
{
int x ;
void * data ;
};

and

struct B
{
int x, y ;
double z ;
void * data1, *data2 ;
};


These structures (not pointers to them), need to be stored in a another struct:

struct C
{
unsigned id ;
char name ;

DATA_TYPE the_struct ;
};


Where DATA_TYPE is EITHER a struct A or struct B.

typedef union {
struct A;
struct B;
} DATA_TYPE;
.



Relevant Pages