Hey,
I am trying to run a program in which i use struct.It will take information form user of students then show it on screen.here is the code and I am getting this error.
"error:'student' undeclared(first use in this function)"
Header is at the last..
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "header.h"
int main()
{
int i ;
int a ;
char h ;
printf("How many students info you want to store:");
scanf("%d", a);
for(i=0;i<a;i++){
struct info student[i] ;
printf("\nEnter his first name:");
scanf("%s", student[i].fname);
printf("\nEnter his last name:");
scanf("%s", student[i].lname);
printf("\nEnter his id number:");
scanf("%d", student[i].id);
printf("\nEnter his class:");
scanf("%d", student[i].clas);
printf("\nEnter his age:");
scanf("%d", student[i].age);
}
printf("\nDo you want to see students info?(y for yes or n for no):");
scanf("%c", toupper(h));
if(h == "Y"){
for(i=0;i<a;i++){
printf("\n%d Student is %s %s", i, student[i].fname, student[i].lname);
printf("\nHis id number is %d", student[i].id);
printf("\nHis class is %d", student[i].clas);
printf("\nHis age is %d", student[i].age);
}
}else{
printf("\nId return exit status 1.");
}
return 0;
}
//This is the header
struct info{
int id ;
int clas ;
int age ;
char fname[25] ;
char lname[25] ;
};