I have problems with certain input areas of my program. There are several parts where the user enters a specific integer. Even if they enter the wrong option, but everything is wonderful and wonderful, but I noticed that if they enter something of a non-integer type, for example "m", this message will be repeated again.
I have a couple of functions that have integer input in them. Here is one for an example.
void Room::move(vector<Room>& v, int exone, int extwo, int exthree, int current) { v[current].is_occupied = false; int room_choice; cout << "\nEnter room to move to: "; while(true) { cin >> room_choice; if(room_choice == exone || room_choice == extwo || room_choice == exthree) { v[room_choice].is_occupied = true; break; } else cout << "Incorrect entry. Try again: "; } }
trikker
source share