Weird loop keep happeneing....pls help debug...
I wrote this program for a project due on the 21st.....
well as it goes into a module SerEmp() it strats to do a weird lopping sequence...
if u go thru option 1 > 4 u can search a record off a file that is opened....and i had included an error msg to catch any items that are not found.....and for some weird reason after the error message shows up....u cannot exit the program etc...it keeps flashing the error message even out of the module....
everything has to stay void as i need to add more to the porgram...but for now...pls
find out why its going out of wack.....i never seen such a logical error...ever....T.T
Quote:
void SerEmp(void)
{ clrscr();
int Target,EmpID,Found;
char check,EmpName[40],DOA[9],DOP[9],DOB[9],Mstat;
FILE *mem,*pay;
if((mem=fopen("E:\\Proj\\Member.dat","r"))==NULL)
{ printf("File is Empty!");
sleep(2);
SerEmp();
}
else
{ printf("Please Enter Employee ID to Search : ");
fflush(stdin);
scanf("%i",&Target);
while (!feof(mem))
{ fscanf(mem,"%i %[^/]%*c %[^/]%*c %[^/]%*c %[^/]%*c %c",&EmpID,EmpName,DOA,DOP,DOB,&Mstat);
if(Target==EmpID)
{ printf("Employee ID : %04i\n",EmpID);
printf("Employee Name : %s\n",EmpName);
printf("Date of Appointment : %s\n",DOA);
printf("Date of Probational Period : %s\n",DOP);
printf("Date of Birth : %s\n",DOB);
printf("Maritial Status : %s\n",&Mstat);
sleep(5);
Employeemgt();
}
else if(Target!=EmpID)
{ printf("Record Not Found, please check Employee Id"); // Here is where it occurs......i can't find what i did wrng....pls help....
sleep(2);
Employeemgt();
}
}
}
//getch();
fclose(mem);
//Employeemgt();
}