Hi, I am trying to make some input code so that if the user enters any number between 1 and 9 then it is valid, if not between 1 and 9 and is any other number OR letter then it will be invalid.
void Input()
{
//integer for input
int choice4;
//players turn
cout << endl;
cout << "It's " << player << "'s turn. " << "Type the number of the field: ";
cin >> choice4;
if (choice4/*Not between 1 and 9*/)
{
cout << "Invalid Input." << endl;
Input();
}
else
{
//edits grid, if 2 replaces 2 field with X or O
choice4--;
grid[choice4 / 3][choice4 % 3] = player;
}
}