Problem with tic tac toe code
Code:
#include<stdio.h>
int
main(void)
{
char tic_tac_toe[3][3] =
{{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}};
char i, j;
for (i=1; i<=3; i=i+1){
for (j=1; j<=3; j=j+1)
{
printf("Please enter symbol in position %d, %d\n",i,j);
scanf("%", &tic_tac_toe[i][j]);
scanf("%*[^\n]");
scanf("%1[\n]");
}
}
void print_board (char tic_tac_toe[3][3]){
int i,j;
for (i = 0; i < 3; i++){
for (j = 0; j < 3; j++){
printf("%c\t", tic_tac_toe[i][j]);
}
printf("\n");
}
}
int has_won (char tic_tac_toe[3][3]){
if (tic_tac_toe[0][0] == tic_tac_toe[0][1] &&
tic_tac_toe[0][1] == tic_tac_toe[0][2]){
printf("%c has won!\n", tic_tac_toe[0][0]);
return 1;
}
else if (tic_tac_toe[2][0] == tic_tac_toe[2][1] &&
tic_tac_toe[2][1] == tic_tac_toe[2][2]){
printf("%c has won!\n", tic_tac_toe[2][0]);
return 1;
}
else if (tic_tac_toe[0][0] == tic_tac_toe[1][0] &&
tic_tac_toe[1][0] == tic_tac_toe[2][0]){
printf("%c has won!\n", tic_tac_toe[0][0]);
return 1;
}
else if (tic_tac_toe[0][1] == tic_tac_toe[1][1] &&
tic_tac_toe[1][1] == tic_tac_toe[2][1]){
printf("%c has won!\n", tic_tac_toe[0][1]);
return 1;
}
else if (tic_tac_toe[0][2] == tic_tac_toe[1][2] &&
tic_tac_toe[1][2] == tic_tac_toe[2][2]){
printf("%c has won!\n", tic_tac_toe[0][2]);
return 1;
}
else if (tic_tac_toe[0][0] == tic_tac_toe[1][1] &&
tic_tac_toe[1][1] == tic_tac_toe[2][2]){
printf("%c has won!\n", tic_tac_toe[0][0]);
return 1;
}
else if (tic_tac_toe[0][2] == tic_tac_toe[1][1] &&
tic_tac_toe[1][1] == tic_tac_toe[2][0]){
printf("%c has won!\n", tic_tac_toe[0][2]);
return 1;
}
else return 0;
}
}