Reputation: 41
I created a loop using the "placeholder" variable just to create a loop so that I can use "continue" with the if statement, which is supposed to give an error message and restart the loop if a number outside of the values (1-7) is entered, but it does not work. Any help is appreciated!
void PlayerOne(char d[ROW][COLUMN], int r[COLUMN])
{
int rtemp, ctemp, mover;
bool placeholder = true;
do
{
cout << "Enter your mover (X): "; cin >> mover; cout << endl;
if ((mover < 1) && (mover > 7))
{
cout << "ILLEGAL INPUT DETECTED" << endl;
continue;
}
rtemp = r[mover];
ctemp = mover - 1;
d[rtemp][ctemp] = 'X';
r[mover]--;
if (placeholder == true)
{
break;
}
} while (placeholder == true);
return;
}
Upvotes: 0
Views: 45
Reputation: 632
Please check this line
if ((mover < 1) && (mover > 7))
Is it possible to mover to be less than 1 and more than 7 at the same time? It will never comes true. I think you should change the binary operand (e.g. "||" by "&&") or change the comparissons. I hope this answer to be useful...
Upvotes: 2