W
well_doing
I have something like this in declaration.
union allInOne{
struct simple_s {
int a;
int b;
} s;
struct complex_s {
int a;
int b;
int rec[10];
} c;
} *p;
In my code, how to implement something like this,
if ( condition A ) {
struct simple_s *ptr = &p->s;
} else {
struct complex_s *ptr = &p->c;
}
ptr->a = 0;
ptr->b = 1;
if ( !condition A) {
ptr->rec[1] = 1;
...
}
union allInOne{
struct simple_s {
int a;
int b;
} s;
struct complex_s {
int a;
int b;
int rec[10];
} c;
} *p;
In my code, how to implement something like this,
if ( condition A ) {
struct simple_s *ptr = &p->s;
} else {
struct complex_s *ptr = &p->c;
}
ptr->a = 0;
ptr->b = 1;
if ( !condition A) {
ptr->rec[1] = 1;
...
}