C Structures
C Structures
struct [structure_tag]
//member variable 1
//member variable 2
//member variable 3
...
}[structure_variables];
Example
struct Student
char name[25];
int age;
char branch[10];
char gender;
};
Here struct Student declares a structure to hold the details of a student which
consists of 4 data fields, namely name, age, branch and gender. These fields are
called structure elements or members.
Each member can have different datatype, like in this case, name is an array
of char type and age is of int type etc. Student is the name of the structure and
is called as the structure tag.
Program
#include<stdio.h>
#include<string.h>
struct Student
char name[25];
int age;
char branch[10];
char gender;
};
int main()
*/
s1.age = 18;
/*
*/
strcpy(s1.name, "Viraaj");
/*
*/
return 0;