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

C Type Qualifiers

C – type qualifiers : The keywords which are used to modify the properties of a variable are called type qualifiers. Types of C type qualifiers: There are two types of qualifiers avai...

C Preprocessor Directives

Before a C program is compiled in a compiler, source code is processed by a program called preprocessor. This process is called preprocessing. Commands used in preprocessor are call...

What are Tri-Graph Characters?

Many non English keyboards do not support all the characters (some special symbols). ANSI C introduces the concept of ‘Tri-graph’ sequences to provide a way to enter certain characters that are no...

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