+ 4
How can we access the elements in structure,where structure present in union?
4 Respostas
+ 8
You either have to use an anonymous struct inside a union like so
typedef union {
struct {
int a;
double b;
};
} un;
and access the members of the struct as
int main() {
un x;
x.a = 5;
x.b = 1.5;
}
or create an object of a regular struct right after the struct definition inside the union like this
typedef union {
struct str {
int a;
double b;
} s;
} un;
and access the members of the struct as
int main() {
un x;
x.s.a = 5;
x.s.b = 1.5;
}
+ 4
I want combination of structures and unions
+ 3
by using the . dot operator between the variable name and the member name.
https://www.sololearn.com/learn/C/2944/
+ 3
Thanq