My code is supposed to take the basic info of 'n' number of drivers, and print it in a nice manner. I have to use structure, but idk why it isn't recognizing driveri.name, and other elements of structure while printing the data, it is showing 'driveri.name undeclared'. NOTE: I've just learnt structures in c, and don't know anything about dynamic memory allocation.
struct manager
{
char name[50];
int dln;
char route[100];
float kms;
};
int main()
{
int n;
printf("Enter the number of drivers\n");
char d;
scanf("%d%c",&n, &d);
for (int i=1;i<=n;i++)
{
struct manager drivieri;
char arr1[50];
printf("\nEnter the name of driver %d\n",i);
gets(arr1);
strcpy(driveri.name, arr1);
printf("\n\n* * * * * * *\n");
printf("The name of Driver %d is: %s",i,driveri.name);
printf("\n* * * * * * *\n\n");
int a;
printf("\nEnter the Driving license number of driver %d\n",i);
scanf("%d",&a);
driveri.dln=a;
printf("\n\n* * * * * * *\n");
printf("The driving license number of Driver %d is: %d",i,driveri.dln);
printf("\n* * * * * * *\n\n");
char arr2[100];
printf("\nEnter the route of driver %d\n",i);
gets(arr2);
strcpy(driveri.route, arr2);
printf("\n* * * * * * *\n");
printf("The route of Driver %d is: %s",i,driveri.route);
printf("\n* * * * * * *\n\n");
float b;
printf("\nEnter the number of kilometers, driver %d have driven\n",i);
scanf("%f", &b);
driveri.kms=b;
printf("\n* * * * * * *\n");
printf("The Driver %d have driven %f kms.",i,driveri.kms);
printf("\n* * * * * * *\n");
}
return 0;
}