Monday 11 March 2013

Nesting of structure


Nesting of structure:

Nesting of structure is possible i.e. we can declare a structure within another structure but it is necessary inner structure must declares structure variable otherwise we can not access the data member of inner structure.
Example:

void main()
{
struct world
{
int a;
char b;
struct india
{
char c;
float d;
}p;
};
struct world st ={1,'A','i',1.8};
clrscr();
printf("%d\t%c\t%c\t%f",st.a,st.b,st.p.c,st.p.d);
getch();
}
Output: 1 A i 1.800000


Blog Author: Vijay Kumar

Go to: Java Aptitude

No comments:

Post a Comment