The program was supposed to close after the user chose 'save and exit' but it goes to 'browse' after the data was saved. Here's the code of my 'main()' and 'saverecords()'
void SaveRecords()
{
FILE *fp;
int ctr;
ctr = 0;
fp = fopen("data.dat", "w");
for (ctr = 0; ctr < count+1; ctr++)
{
fprintf(fp, "%s ", whois[ctr].name);
fprintf(fp, "%s ", whois[ctr].id_no);
fprintf(fp, "%s ", whois[ctr].course);
fprintf(fp, "%s ", whois[ctr].year);
}
fclose(fp);
}
main()
{
int choice, a;
again:
clrscr();
printf("\n Menu:");
printf("\n [1] Load Record");
printf("\n [2] Add");
printf("\n [3] Browse");
printf("\n [4] Change");
printf("\n [5] Delete");
printf("\n [6] Save and Exit");
printf("\n\n choice: ");
choice=getch();
switch(choice)
{
case '1':
showmenu();
break;
case '2':
add();
break;
case '3':
browse();
break;
..etc..
case '6':
SaveRecords();
break;
default:
printf("\n\n\n Invalid Choice!!! Try again...");
getch();
goto again;
}
return 0;
}
I hope you guys could help me out with this.
2007-03-03
22:40:20
·
3 answers
·
asked by
Lhanz
1
in
Computers & Internet
➔ Programming & Design
I've tried
[quote]case '6':
SaveRecords();
if (choice == 6) exit; //or goto stop label
break;[/quote]
but the system says, "undefined symbol exit". What should I do with it?
2007-03-06
13:08:48 ·
update #1