I have simple the nested structure:
struct abc {
int i;
};
struct milan {
struct abc obj;
};
int main()
{
struct milan *ptr;
ptr = malloc(sizeof(struct milan));
ptr->obj.i = 10;
printf("%d\n", ptr->obj);
}
It prints 10, but how the de-reference a pointer taking place here, is ptr->obj the same as &->obj == *obj ?
The expression
ptr->objis the same as( *ptr ).obj.From the C Standard (6.5.2.3 Structure and union members)
and