References to struct members have such a pattern:
Arrow (): The left must be a pointer;
Point number (.): The left must be an Entity.
So what if a struct pointer refers to a member and the member is a struct (and an entity), what if you want to refer to the members of this member?
After the experiment found, still follow the above rule namely: the arrow left must be the pointer, the entity must use the dot number reference. For example C->student.age
eg.
You start with an arrow that's C->s1->age.
#include"stdio.h"intmain () {structstudent{intage ; intclass_; }; structclass2{structStudent s1; }; structClass2 *c; structClass2 cc={. S1={. age=9,. Class_=2 } }; C=&cc; printf ("%d",c->s1->age ); return 0;}
An error occurs as Follows:
If you change the code to c->s1.age, the code is as Follows:
#include"stdio.h"intmain () {structstudent{intage ; intclass_; }; structclass2{structStudent s1; }; structClass2 *c; structClass2 cc={. S1={. age=9,. Class_=2 } }; C=&cc; printf ("%d",c->s1.age); return 0;}
Compile by getting the result of the Run:
(c) struct member references (arrows) and. (points)