Nested Structures :
Structure within structure is called as nested structures. We can declare a structure within another structure.
Example :
struct struct1
{
struct1-member declarations
struct sub-structA
{
substructA-member declarations
}sub-structA-variable;
struct sub-structB
{
substructB-member declarations
}sub-structB-variable;
|
|
|
}struct1-variablename;
Example:
struct Office
{
char location[30];
struct Dept
{
int dno;
char dname[30];
}d;
struct Emp
{
int eno;
char ename[30];
}e;
}O;
Structure within structure is called as nested structures. We can declare a structure within another structure.
Example :
struct struct1
{
struct1-member declarations
struct sub-structA
{
substructA-member declarations
}sub-structA-variable;
struct sub-structB
{
substructB-member declarations
}sub-structB-variable;
|
|
|
}struct1-variablename;
Example:
struct Office
{
char location[30];
struct Dept
{
int dno;
char dname[30];
}d;
struct Emp
{
int eno;
char ename[30];
}e;
}O;
Comments
Post a Comment