If all you're actually trying to do is find the first empty space and replace it with an O then this would do it:
//Set all spaces to ' ' when you initialize the board for (int i = 0; i < 8; ++i) //Where 8 is the size of the board { board[i] = ' '; } //Then when you're wanting to replace the first empty space wth 'O' for (int i = 0; i < 8; ++i) { if (board[i] == ' ') board[i] = 'O'; }
if you do not put a break in that if statement, it will change ALL empty spaces into O's, rather than the first one you find
If (board[i] =='')
{
board [i] = 'O';
break;
}
that way only one empty is changed
also i think you may want 9 instead of 8; arent there 9 tiles in TTT?