i designed this tic tac code in c bt there is sum prblm wid the part where program has to decide the winner it dosent seem 2 workin im posting the code any help is greatly supported
#include<stdio.h>
#include<conio.h>
void main ()
{
int go=0;
int i =0;
int player;
int row=0;
int column=0;
int winner=0;
int line=0;
char board[3][3]={
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};
printf("\n\n");
printf("%c| %c| %c| \n", board[0][0],board[0][1],board[0][2]);
printf("---|---|--- |\n");
printf("%c| %c| %c| \n", board[1][1],board[1][2],board[1][3]);
printf("---|---|--- |\n");
printf("%c| %c| %c| \n", board[2][1],board[2][2],board[2][3]);
for(i=0;i<9;i++)
{
player=(i%2)+1;
printf("hi player %d please indicate position where u want 2 place %c \n", player,(player==1)?'x':'o');
scanf("%d",&go);
row=--go/3;
column=go%3;
board[row][column]=(player==1)? 'x':'o';
printf("\n\n");
printf("%c| %c| %c| \n", board[0][0],board[0][1],board[0][2]);
printf("---|---|---| \n");
printf("%c| %c| %c| \n", board[1][0],board[1][1],board[1][2]);
printf("---|---|---| \n");
printf("%c| %c| %c| \n", board[2][0],board[2][1],board[2][2]);
printf("---|---|---| \n");
scanf("%d", board[row++][column++]);
}
if(i<9);
{
goto chk;
chk:
{
if((board[0][0]==board[1][1]&& board[0][0]==board[2][2])||
(board[0][2]==board[1][1]&& board[0][2]==board[2][0]))
winner=player;
}
{
for(line=0;line<=2;line++)
if((board[line][0]==board[line][1]&& board[line][0]==board[line][2])||
(board[0][line]==board[1][line]&& board[0][line]==board[2][line]))
winner=player;
}
if((board[0][0]==board[1][0]&&board[0][0]==board[2][0])||
(board[0][1]==board[1][1]&&board[0][1]==board[2][1])||
(board[0][2]==board[1][2]&&board[0][2]==board[2][2]))
winner=player;
}
printf("player%dwins\n",winner);
}