ARRAY OF STRUCTURE
An array of structure can be created to store multiple instances of the same structure type.
#include <stdio.h>
// Define a structure named 'Person'
struct Person {
char name[50];
int age;
float height;
};
int main() {
// Declare an array of structures 'people' with 3 elements
struct Person people[3];
EXAMPLE :
C program to read name, roll and age of 5 students ans display them using structure.
#include<stdio.h>
#include<conio.h>
struct student
{
char name[50];
int age;
int roll;
};
int main()
{
struct student s[5];
int i;
printf("Enter name, roll and age of student");
for(i=0;i<5;i++)
{
gets(s[i].name);
scanf("%d",&s[i].roll);
scanf("%d",&s[i].age);
}
printf("Display the information");
for(i=0;i<5;i++)
{
printf("Name=%s\nRoll=%d\nAge=%d\nSum=%d",s[i].name,s[i].roll,s[i].age);
}
return 0;
}