Hi guys,
I'm going to write a program which i had to get at most 200 student informations and then sort them in some ways, getting input will continue until user enter EOF or 200 students information entered.
i wrote a struct for students contain firstName, lastName and studentCode.
firstName maximum size is 20 chars.
lastName maximum size is 50 chars.
studentCode maximum size is 7 chars.
and a flag to check if that segment of students array is active or not.
here is what i wrote:
the problem i have, is working with EOF,Code:#define TRUE 1 #define FALSE 0 #include<stdio.h> #include<stdio.h> struct Student { charfirstName[20]; charlastName[50]; charstudentCode[7]; int flag; }; void studentInitializeser (struct Student* student); int main(void) { struct Student students[200]; int i=0; for(i=0;i<200;i++) studentInitializeser(&students[i]); i=0; gets(students[0].firstName); while(students[i].firstName!=EOF) { gets(students[i].lastName); gets(students[i].studentCode); students[i]. flag=TRUE; i++; gets(students[i].firstName); } return0; } void studentInitializeser(struct Student* student) { student->flag=FALSE; inti=0; for(i=0;i<20;i++) student->firstName[i]=" "; i=0; for(i=0;i<50;i++) student->lastName[i]=" "; i=0; for(i=0;i<7;i++) student->studentCode[i]=-1; }
i know that gets function return NULL if EOF entered, but i tried that too, its not working ^Z(i'm using Ubuntu) but program still waiting for input.
i attached a picture of running program.
thanks in advance for your helps.