Hi,
I'm writing a code for tictactoe game, my code compiles, but when I try to input the values, it doesn't work properly.
here's function for the input.
Code:
void enter_symbol(char ttt[][3], int player)
{
int row, col;
while(1)
{
printf("Player 1 plese specify where you would like to enter a symbol, and enter it\n");
scanf("%d", &row);
scanf("%d", &col);
if(ttt[row][col] ==' ')
{
ttt[row][col]='x';
break;
}
else
printf("Position you specified is already taken, try again\n");
}
while(1)
{
printf("Player 2 plese speficy where you would like to enter a symbol, and enter it\n");
scanf("%d", &row);
scanf("%d", &col);
if(ttt[row][col] ==' ')
{
ttt[row][col]='o';
break;
}
else
printf("Position you specified is already taken, try again\n");
}
}
Here's what i get when i run it
Code:
Player 1 plese specify where you would like to enter a symbol, and enter it
11
12
Position you specified is already taken, try again
Player 1 plese specify where you would like to enter a symbol, and enter it
13^H^H
hulk:~/Lab07>tictactoe
Player 1 plese specify where you would like to enter a symbol, and enter it
11
12
Position you specified is already taken, try again
Player 1 plese specify where you would like to enter a symbol, and enter it
12
13
Position you specified is already taken, try again
Player 1 plese specify where you would like to enter a symbol, and enter it
can you see what's wrong with it? I can't.
Thanks