A structure is a user defines data type, which is a combination of pre-defined data types. A structure can be declared as follows:
struct
dept
{
int
deptid;
char
deptname[20] ;
float
avgEmpSal;
};
The structre name says
dept followed by the keyword struct. Then inside the structure
you can place the predefined data types that together forms a user defined
type. Usually we call these pre-defined types insdie the structure as data
members.
The below statement
creates the user defines variable of type dept.
struct
dept sales;
To acces the members
use the period operator on the variable sales like as shown
below:
sales.deptid = 101;
Below is the example
of using a stucture:
#include
"stdafx.h"
#include
<stdio.h>

Join the conversation! Your thoughts help the community grow.