Accessing Element in Structure Array

  1. Array of Structure can be accessed using dot[.] operator.
  2. Here Records of 3 Employee are Stored.
  3. Array of Structure can be accessed using dot[.] operator.
  4. Here Records of 3 Employee are Stored.

Example

#include<stdio.h>
#include<conio.h>
struct Employee{
int ssn;  char ename[20];  char dept[20];
}emp[3];
//---------------------------------------------
void main(){
int i,sum;//Enter the Employee Details
for(i=0;i<3;i++) {
 printf(Enter the Employee Details :);
 scanf("%d %s %s",&emp[i].ssn,emp[i].ename,emp[i].dept);
 }//Print Employee Details
for(i=0;i<3;i++)
{ 
printf("nEmployee SSN   : %d",emp[i].ssn);
printf("nEmployee Name  : %d",emp[i].ename);
printf("nEmployee Dept  : %d",emp[i].dept);
}
getch(); 
}

Output

Enter the Employee Details : 1 Ram Testing
Employee SSN : 1 
Employee Name : Ram Employee Dept : Testing