Array of Structure Variable
Like variables
of built in data types it is also possible to create an array of structure variable. Syntax
struct structure_name array_name[SIZE]; Example: struct Student S[60]; In above example
S[0] represents First student, S[1] represents second student and so on. Example
#include<stdio.h> #include<conio.h> struct student { int rollno; char name [20]; }; void main () { clrscr (); struct student s[60]; int i; for (i=0; i<60; i++) { printf ("Enter Roll Number:"); scanf ("%d", &s[i].rollno); printf ("Enter Name:"); scanf ("%s", s[i].name); } for (i=0; i<60; i++) { printf ("Roll Number: %d\n", s[i].rollno); printf ("Name: %s\n", s[i].name); } getch (); } |