} int numStudents = getData(in, pupil); if(numStudents==0){ printf("No data supplied for students\n"); exit(1); } for(int h=0;h<numStudents;h++){ printStudent(pupil[h]); } printf("\n"); getString(in, aname); while(strcmp(aname,"END") != 0) { int ans = search(aname, pupil, numStudents); if(ans==-1) printf("%s not found \n", aname); else printf("%s found at location %d\n",aname,ans);
}// while end getString(in, aname); sort(pupil, numStudents); printf("\n"); for (int h=0;h<MaxStudents;h++){ printStudent(pupil[h]); } }//main end void printStudent(Student t){ printf("Name :%s, Age:%d, Gender:%c\n",t.name,t.age,t.gender); } //end printStudent int getData(FILE *in, Student list[]) { char temp[MaxNameBuffer]; void getString(FILE *, char[]); char readChar(FILE *); int n=0; getString(in,temp); while(n<MaxStudents && strcmp(temp,"END")!=0){ strcpy(list[n].name,temp); fscanf(in,"%d",&list[n].age); list[n].gender=readChar(in); n++; getString(in,temp); } return n; }