Breaking News

Structures with in structures

Structures within a structure means nesting of structures.


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

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];
int dearness;
int house_rent;
int city;

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.

Check Also

Type modifier In C Programming Language

The basic data types may have modifier preceding them to indicate special properties of the object being …