If statement acting weird. For some reason if in the IF statement `if ( choosePositionX )` goes to else which tells the user the other player already made the move it goes into the next if `if ( choosePositionO )` and prints out the else in that one. How can i make it so once it goes to else in either if statement that it just breaks out and continues down. it seems that break; doesnt work. So basically my problem is that the other else in the other statement follows the first one and so on.
void makeMove()
{
if (choosePositionX)
{
if (ticTacBoard[choosePositionX - 1] != 'X' && ticTacBoard[choosePositionX - 1] != 'O' )
{
ticTacBoard[choosePositionX - 1] = 'X';
}
else
{
cout << "Player O has already made this move" << endl << endl;
// keep same moves for counter draw
totalMoves = totalMoves - 1 + 1;
}
}
if (choosePositionO)
{
if (ticTacBoard[choosePositionO - 1] != 'X' && ticTacBoard[choosePositionO - 1] != 'O' )
{
ticTacBoard[choosePositionO - 1] = 'O';
}
else
{
cout << "Player X has already made this move" << endl << endl;
// keep same moves for counter draw
totalMoves = totalMoves - 1 + 1;
}
}
}