Write about Structures within Structures?


Structures within a structure mean nesting of structures. Nesting of structures is permitted in C.

For example: The following Structure defined to store information about the salary of employees.

struct salary
{
char name;
char dept;
int basic;
int dearness_allowance;
int house_rent_allowance;
int city_allowance;
} emp;

This structure defines name, department, basic pay & 3 kinds of allowances. We can group all the items related to allowance together and declare them under a structure as shown below.

struct salary
{
char name;
char dept;
struct;
{
int da;
int hra;
int city;
}
allowance;
}
emp;

The salary structure contains a member named allowance. Which itself is a structure with 3 members. The members contained in the inner structure namely da, hra and city can be referred to as :

emp.allowance.da;
emp.allowance.hra;
emp.allowance.city;


Related

How to Pass Structure Values as Parameters to Functions?

C supports the passing of structure values as arguments to functions. There are 3 methods by which the values of a structure can be transferred from one function to another. 1. The 1st method is to...

How to Pass Arrays to Functions?

One Dimensional Arrays: Like the values of simple variables, it is also possible to pass the values of an array to a function. To pass a one dimension array to a called function, it is sufficient ...

What are the Various Input/Output Functions used in Files?

In C the input, output operations with files are performed with the help of library functions. Once a file is opened, reading out of or writing to it is accomplished using the standard I/O routines....

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item