English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

3 answers

case '6':
SaveRecords();
if (choose==6) exit; //or goto stop label
break;

2007-03-04 01:35:07 · answer #1 · answered by iyiogrenci 6 · 0 0

In an desirable international you need to upload validation to ascertain the fee of the lower back fee yet it really is homework so there is no opt for. replace this printf("***** make investments Calculator *****n"); to // repeat processing loop do { printf("***** make investments Calculator *****n"); Now upload this to the top of your pattern code. printf("do you opt for to have a clean calculation? (certain:a million/No:0)n"); scanf("%d", &proceed); } even as (proceed==a million); proceed also should be declared as int. have thrilling.

2016-11-27 20:28:35 · answer #2 · answered by ? 4 · 0 0

Try end, make sure u unload your forms first.

2007-03-03 22:46:35 · answer #3 · answered by Michael Burns 4 · 0 0

fedest.com, questions and answers