I recently wrote this tic tac toe program, and it does everything I want it to do, but I was wondering if there were any more efficient tactics I could've used, particularly with error checking the user input and recognizing the winner?
int row_choice, column_choice;
int turnCount = 0;
cout << "One person is X's and one person is O's." << endl;
cout << "X goes first." << endl;
do
{
cout << "Enter the numbers for the row and column where you want to play." << endl;
cin >> row_choice>>column_choice;
while (cin.fail())
{
cout << "This was an invalid input." << endl;
cin.clear();
cin.ignore(80, '\n');
cout << "Please re-enter the numbers." << endl;
cin >> row_choice>>column_choice;
}
while (row_choice > 3||row_choice < 1||column_choice > 3 || column_choice < 1)
{
cout << "That is not a valid placement." << endl;
displayTable(table);
cout << "Enter the numbers for the row and column where you want to play." << endl;
cin >> row_choice >> column_choice;
}
while (table[row_choice][column_choice] != '*')
{
cout << "That spot is already taken." << endl;
displayTable(table);
cout << "Enter the numbers for the row and column where you want to play." << endl;
cin >> row_choice >> column_choice;
}