C Structure

In Array, we can store data of one type only, but the structure is a variable that gives facility of storing data of different data type in one variable. Structures are variables that have several parts each part of the object can have different types. Each part of the structure is called a member of the structure.

Declaration

Consider basic data of student :
roll_no, class, name, age, address.

A structure data called student can hold all this information:

before the final semicolon, At the end of the structure’s definition, we can specify one or more structure variables. There is also another way of declaring variables given below.

Initialization

Structure members can be initialized at declaration. This is the same as the initialization of arrays; the values are listed inside braces. The structure declaration is preceded by the keyword static.

static struct student work ={1000,”ch”,”x”};

Accessing structure data

To access a given member the dot notation is used. The “dot” is called the member access operator.

Scope

A structure type declaration can be local or global, depending upon where the declaration is made.

Output