# Defining a Structure

Defining a Structure is a process of creating the skeleton of physical object that can be understood by compiler .It consists of Structure name and the description of it’s member(property).

Definition of a structure creates a template are format that describes the characteristics of it’s member .

The general syntax of a structure definition is:

Struct structurename{
               Datatype member1;
               Datatype member2;
               …………………………………..
               Datatype membern; 
                        };
1
2
3
4
5
6

Here struct is a keyword , which tells the compiler that a structure is being defined . member1 , member2 ,………,membern are the member of structure and are declared inside curly bracket .

There should be a semicolon at the end of the curly braces

(adsbygoogle = window.adsbygoogle || []).push({});

These member can be of any data type like int , char , float , array , pointer or another structure

Structurename is the name of the structure and is used further in the program to declare Structure variables of this types

Definition of a structure provides and more data type that can be used in program

It is important to note that definition of structure does not reserve any space in memory for the members.Although the syntax of the declaration of member inside the definition of Structure is identical to the syntax we use in declaring variables but they are not variables . They do not have any existence until they are attached with a structure variables.

The member name should be different inside the structure definition but it can be same outside the Structure definition and inside other Structure definition.

Let us take an example of defining the Structure :

e.g:

struct man{
           char name[21];
           int rollno;
           float salary;
                };
1
2
3
4
5

Here man is the Structure name and there are three member i.e name, rollno , salary.

Structure can be defined globally or locally