why does the "multiples++" variable have any effect in the code although it isnt used any where while calculation of the multiples? the programme should only show the values of the "counter" variable.
// Right now the only way to exit the loop and program is the select number 4
while (true)
{
int input;
cout << "1. Play game\n";
cout << "2. Load game\n";
cout << "3. Play multiplayer\n";
cout << "4. Exit\n";
cout << "Selection: ";
cin >> input;
switch ( input )
{
case 1:
playgame();
break;
case 2:
loadgame();
break;
case 3:
playmultiplayer();
break;
case 4:
cout << "Thank you for playing!\n";
// You could use break; instead of return 0; if you want to only exit the loop and not the
// whole program.
return 0;
default:
cout << "Error, bad input, quitting\n";
break;
}
}
I would also suggest you indent each scope instead of having them all at the beginning so that the program is easier to read.
but doing this just puts it in an infinite loop if anything else is typed .
The default just keeps looping. I wanted to know if there was any way to give the user a second chance for entering when the default statement is printed.