This works too:
int main()
{
begin:
//main code over here
restartchoice:
char choice;
cout << "Do you wish to start again?(y/n): ";
cin >> choice;
switch(choice)
{
case 'Y' :
case 'y' :
goto begin;
break;
case 'N' :
case 'n' :
goto end;
break;
default:
cout << "You must either enter Y to start again, or N to end the program." << endl << endl;
system("pause");
goto restartchoice;
}
end:
return 0;
}
Wiki_Tiki
Junior Poster in Training
60 posts since Jul 2008
Reputation Points: 23
Solved Threads: 3
Wiki_Tiki
Junior Poster in Training
60 posts since Jul 2008
Reputation Points: 23
Solved Threads: 3
You do realize that this thread is over three years old?
...And that using goto for this instead of a loop is Wrong...
...And that this is the Pascal and Delphi forum...
(But at least you didn't call main(); ;) )
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229