I just came across a piece of code: -
struct a {
int mem1;
char mem2;
struct {
int inner_mem1;
int inner_mem2;
};
};
And I found that a code snippet using internal structure elements directly using the name of an external struct variable !!! eg:
struct a *avar;
....
avar->inner_mem1
Whether it is legal, the code compiles and works fine !. What is the purpose of using it in this way? Any specific scenarios?
Please let me know your thoughts.
source
share