Accessing members of Nested Structure in C language – Example of Structure with in Structure.
This code snippet will access the members of Nested Structure in C programming language, this program will demonstrate working with structure within structure i.e. Nested Structure.
C Code Snippet - Access members of Nested Structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <stdio.h>
struct Outer{
int oVar;
struct Inner{
int iVar;
}IN;
}OUT;
int main()
{
OUT.oVar=10;
OUT.IN.iVar =20;
printf ( "oVar: %d, iVar: %d\n" ,OUT.oVar, OUT.IN.iVar);
return 0;
}
|
oVar: 10, iVar: 20