Structure within structure

Structure within structure: The structure within structure is called the nested structure.

e.g      

struct student

{

int roll_num;

char name[20];

struct

{

int age;

float weight;

}info;

}std;

In above example we can see that how structure within structure can be declared as well how structure variables are declared in this case.

Access of inner data-members: To access the data-member of the inner structure we have to mention outer structure variable and then inner structure variable.

e.g:      Taking the above example if we want to access ‘age’ then it will be as:

            std.info.age

Posted in C

Leave a Reply

Your email address will not be published. Required fields are marked *