i have an array that looks like this after it has been populated:
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
When i enter the input of 1 it should put a 'O' in the array at [6][0] but while doing that it also enters a 'O' at [5][7] and it looks like this:
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . 0
0 . . . . . . .
how can i make it so it only enters where it should go.
playerSymbol is 'O' , player is 1, col 7
int playerMove (char array [][COL], char playerSymbol, int player)
{
int colselect = 0;
int rowselect = 6;
cout << "Player " << player << " move: ";
cin >> colselect;
bool entered = false;
while ((entered != true) && (rowselect >= 0))
{
if (array [rowselect][(colselect - 1)] == '.')
{
array [rowselect][(colselect - 1)] = (playerSymbol);
entered = true;
}
else
rowselect -= 1;
}
if (rowselect < 1)
{
cout << "invalid input" << endl;
playerMove(array, playerSymbol, player);
}
return colselect;
}