If I input something that my switch doesn't want to accept (I actually have 4 cases) the code will not stop for the cin>> the second time through. I had a previous version of this code call menu() right before the break; in the default case but that was also causing an finite loop. This and this and a few others have not helped me. I can't seem to tell why cin just doesn't want to get called.
void menu()
{
bool running = true;
int answer = 0;
std::vector<Player> players;
Dealer river;
while (running)
{
std::cout << "1. Start Round\t2. Add Player\t3. Remove Player\t4. Exit\n\n";
std::cin.clear();
std::cin >> answer;
std::cin.ignore(std::numeric_limits <std::streamsize> ::max(), '\n');
std::cout << answer;
switch (answer) {
case 1:
//doesn't matter
break;
default:
std::cout << "Invalid input.\n";
break;
}
}
}