Donate

1 Structures with in structures-Structures

Structures within a structure means nesting of structures.

Example:

struct salary
{
char name [20];
char department [10];
int basic-pay;
int dearness-allowance;
int huse_rent_allowance;
int city_allowance;
}
employee;

This structure defines name, department, basic pay and three kinds of allowances.

All the items related to allowance can be grouped together and declared under a sub-stricture. As shown below, strut salary

{
char name []2;
char department [10];
struct;
}
int dearness;
int house_rent;
int city;
[allowance;
}
employee's;

The salary structure contains a member named allowance which use is a structures with.

Three members. Now ; the member compared in the inner structure;, namely, ;dearness, house_rent and city can ;be left to as;

employee. ;allowance. Dearness
employee. Allowance. House_rent
employee allowance. city

The inner most member in a nested structure can be accessed by chaining all the concerned structure variables (from outermost to inner most) with the member using dot operator.

If you enjoyed this post, make sure you subscribe to my RSS feed!


1 comments to "Structures with in structures-Structures"
Anonymous
on May 24, 2008 at 7:18 AM  

hi! :)
thanks for the visit!
if you want, i already added your link on this page, coz i don't add links on the homepage.

i hope u understand.

by the way, nice blog you got here, i love the header.

Post a Comment