I just came across a code snippet say:-
struct a {
int mem1;
char mem2;
struct {
int inner_mem1;
int inner_mem2;
};
};
And I found that the code snippet using the inner struct's members directly using the outer struct's variable name!!! ex:
struct a *avar;
....
avar->inner_mem1
Is this legal, the code is compiling however and working fine!. What is the purpose to use it in this way? Any specific scenarios ?
Please let me know your thoughts.