×
☰ Menu

Declaration of Structure 

After defining a structure format, you can declare that type. A structure variable declaration is similar to the declaration of variables of any other data type. It includes the following elements.

  • The keywords struct
  • The structure tag name.
  • List of variable names separated by commas.
  • A terminator (Semicolon).

A structure variable can either be declared with a structure declaration or as a separate declaration like basic types.

struct person
{
  char name[50];
    int citNo;
    float salary;
};
int main()
{
    struct person person1, person2, person3;
    return 0;
}

 

Another way of creating a structure variable is:

 

struct person
{
    char name[50];
    int citNo;
    float salary;
} person1, person2, person3;