1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void enterNum(int player){
cout << "This is player " << player << endl;
while (cin)
{
cout << "Enter column number (1-9):" << endl;
cin >> column;
if (column < 1 || column > 9) continue;
column -= 1;
if (coor[column][0])
cout << "Column is full. Try again.\n";
else
break;
}
|
By the way, it is difficult to follow your board.
Standard Connect4 is 7 columns by 6 rows.
Users may have an easier time if you print { '-', 'X', 'O' } for { 0, 1, 2 }, for example. (Pick anything you like, though.)
Also, don't forget to check for winner or stalemate after every move.
You can, BTW, reduce that loop in main() by tracking whose turn it is.
I would move the
column variable out of global scope, too.
Hope this helps.