I have tried this code for printing some persons' basic information. Here is the code :
#include <stdio.h>
struct person {
char name[100];
int age;
float salary;
};
int main() {
struct person p[3];
int i;
for(i=0;i<3;i++){
printf("Enter informations for person no %d:\n\n",i+1);
printf("Enter name : \n");
gets(p[i].name);
printf("Enter age : \n");
scanf("%d",&p[i].age);
printf("Enter salary : \n");
scanf("%f",&p[i].salary);
}
for(i=0;i<3;i++){
printf("\n\nInformations for person no %d:\n\n",i+1);
printf("Name: %s\n",p[i].name);
printf("Age : %d\n",p[i].age);
printf("Salary : %0.2f\n",p[i].salary);
}
return 0;
}
Now while scanning data, this code takes only takes all the information of first person and doesn't take character type data of others.