| Structures |
| |
| Structures with in 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. |
| |
| |
| |
| |
| |