If you're defining playersRespond to be an integer, you need to remove the ' ' from around the 1, 2 and 3 (your if, else if and your while lines).
*Edit* What are you trying to do? Because if someone enters in a 1 or 2 you do something, otherwise you get the "Please enter 1, 2 or 3" message. You also get this message if playersRespond == 3 first time round. And why the char c bit? c has no impact, if playersRespond isn't 3 the 1st time around, you'll get an infinite loop. It makes no sense. Are you trying to do something like this?:
*Edit* What are you trying to do? Because if someone enters in a 1 or 2 you do something, otherwise you get the "Please enter 1, 2 or 3" message. You also get this message if playersRespond == 3 first time round. And why the char c bit? c has no impact, if playersRespond isn't 3 the 1st time around, you'll get an infinite loop. It makes no sense. Are you trying to do something like this?:
Code:
#include <ctime>
#include <iostream>
using namespace std;
void main() {
srand(time(NULL));
int guess = rand() % 99 + 1, playersRespond;
cin >> playersRespond;
do {
if (playersRespond == 1) {
// do something
} else if (playersRespond == 2) {
// do something else
} else if (playersRespond == 3) {
// response is already 3, break out of this?
break;
} else {
cout << "Please type in 1, 2 or 3\n";
cin >> playersRespond;
}
} while (playersRespond != 3);
}
