Hello, I need help with this Tic-Tac-Toe game. I am new to c++ and I understand I could have written this code much shorter than I did. Please dont change all the code I just need help with a few things. I need to make it so if I enter anything other than 1-9 it will give you an error not just go into an infinite loop. Please help!!
int x;
// ask the user to enter a number from 1-9 inclusive
cout << "Enter a number from 1-9: "
cin >> x;
//check input number
if ((x > 0) && (x < 10)) {
//valid input, do something
}
else {
//Invalid input, give an error!
}