int main()
{
int retry = 1;
char input = 'y';
LOOP: // a label used for goto
cout << "\nTry #" << retry++;
cout << ": Continue (Y)? ";
cin >> input;
switch (input)
{
case 'n':
case 'N': break; // terminates the loop
case 'y':
case 'Y':
default: goto LOOP;
}
// exit the program
return 0;
}
// a user-defined function
bool FunctionLOOP()
{
char input = 'y';
cout << ": Continue (Y)? ";
cin >> input;
switch (input)
{
case 'n':
case 'N': return false; // terminates the loop
case 'y':
case 'Y':
default: break;
}
return true;
}
int main()
{
int retry = 1;
bool flag = true;
while (flag)
{
cout << "\nTry #" << retry++;
flag = FunctionLOOP();
}
//exit the program
return 0;
}