Now let us see how to access members of a nested structure.
In this example, the structure
date
is used in the structure
Emp. A particular member inside the
structure can be accessed by repeatedly applying the dot (.) operator.
For example,
in this statement,
emp.dob.day = 5;
we set the day variable in the
dob
structure within
emp
to 5. Similarly, other members of a nested
structure are accessed as follows:
emp.dob.month = 3;
emp.dob.year = 2016;
Also we can display the members of a nested structure as follows:
printf(“%d”, emp.dob.day);
printf(“%d”, emp.dob.month);
printf(“%d”, emp.dob.year);
Note that this level of nesting can go up to any level. There is no limit. Also note that a
Do'stlaringiz bilan baham: |