Basically this is a small part in a big program I've developed, I've managed to create an entire game of monopoly, now I've only got one error left... and it's really silly one too.
When I input the number of players as anything else but a number, the loop is being ignored and continually outputs the same line.
1 2 3 4 5 6 7 8 9 10 11 12 13
int players = 0;
cout << "Welcome to Monopoly" << endl;
cout << "How many players do you want? (2 - 6)" << endl;
cin >> players;
//checking if players are between 2 and 6
while(players > 6 || players < 2)
{
cout << "players must be between 2 n 6" << endl;
cin >> players;
}
I've tried cin.ignore, I've tried cout << flush, I've tried converting it to a string and float, then back too and int, I've tried resetting the int within the loop...
Nothing works.
So any help would be much appreciated. Thanks Olly