Skip to content
doubtly

1 answer

Best answer

Answer: A nested structure is a structure that contains another structure (a structure variable) as one of its members.

When one of the members of a structure is itself a structure, the outer structure is called a nested structure. It is used to group related data, for example a student's date of birth inside the student record.

struct Date {
    int day, month, year;
};

struct Student {
    int roll;
    char name[30];
    struct Date dob;      /* structure inside a structure */
};

struct Student s = {1, "Asha", {15, 8, 2007}};
printf("%d/%d/%d", s.dob.day, s.dob.month, s.dob.year);

Here struct Student has a member dob of type struct Date, so Student is a nested structure. Members of the inner structure are reached with the dot operator twice: s.dob.day. The inner structure can be declared separately (as above) or defined directly inside the outer structure.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.