So I have a tic-tac-toe game for my Intro to C++ class that I have almost completed. I have two issues that I cannot seem to figure out for the life of me.
The board displays as such:
1 2 3
4 5 6
7 8 9
Each player enters a number 1-9 to assign their space. This mostly works except I cannot get it to reject double-digit numbers. Instead, it uses a turn for each digit, which is my first problem.
My second problem is the if statement to end the game when a player has won: it breaks the loop of the game in the first turn and declares a winner improperly. Any help or insight in either of these would be fantastic and greatly appreciated!
int main ()
{
char gb[3][3];
char p; // player input
char XorO;
bool playerx = true; // true is X, false is O
int num_moves = 0;
.
It is also hard to tell what the problem is because of the ill-formated program try to use proper indentation.
1 2 3 4 5 6 7 8 9 10
int main()
{
loop()
{
if()
{
stuff
{
}
}
as far as question one goes I think you are missing the avail spot function and the input of where the player is moving to. All I see is the input for which person is moving not where they are moving to.
Question 2 I have no idea what the 2d-array gb is supposed to be....and your if/else if/else statements are very confusing imo.
Also it looks like the second set of if/else if statements are useless because you are already going through those cases in the for loop except for the [0][3] one which is invalid at your 9th to last line. elseif (((gb[0][3] + gb[1][1] + gb[3][0]) == 264) || ((gb[0][3] + gb[1][1] + gb[3][0]) == 237))