I only changed two things, but I don't think it really helped...
I am just posting this to help spread out your code
btw: use the [ c o d e ] tags
Code:
#include <stdio.h>
#include <string.h> /*sets up 2 strings so names can be used*/
char oxo[4][4];
void display_grid();
int main(void)
{
int r1,c1,r0,c0,rx,cx,count;
int name1[20],name2[20]; /*defines name1 & name2 are variables */
for(r1=1;r1<=3;r1++)
{
for(c1=1;c1<=3;c1++)
{
oxo[r1][c1]='-';
oxo[0][1]='1'; /**/
oxo[0][2]='2'; /*prints column numbers*/
oxo[0][3]='3'; /**/
oxo[1][0]='1'; /**/
oxo[2][0]='2'; /*prints row numbers*/
oxo[3][0]='3'; /**/
}
}
system ("clear");
printf("\n Player 1 what is your name?\n"); /*asks player 1 1s name*/
scanf("%s",name1); /*reads name*/
printf("\nHello %s you place the '0's & you go first! \n",name1); /*print out */
printf("\n Player 2 what is your name?\n"); /*asks player 1 2s name*/
scanf("%s",name2); /*reads name*/
printf("\nHello %s you place the 'X's & you go second!\n",name2); /*print out */
system ("clear");
display_grid();
count=0;
while(count<9)
{
if(count<9)
{
do{
printf("%s enter you next move, '0's\n",name1); /*asks for m move by name*/
scanf("%d%d",&r0,&c0);
system ("clear");
}
while((oxo[r0][c0]!='-')||(oxo[r0][c0]=='X')||(oxo[r0][c0]=='0'))
{
oxo[r0][c0]='0';
}
count++;
} display_grid();
/*These lines look to see if there is a row of 0s in any of the 8 ways possible program looks to see if 0s have won*/
if ((oxo[1][1]=='0'&&oxo[1][2]=='0'&&oxo[1][3]=='0')||
(oxo[2][1]=='0'&&oxo[2][2]=='0'&&oxo[2][3]=='0')||
(oxo[3][1]=='0'&&oxo[3][2]=='0'&&oxo[3][3]=='0')||
(oxo[1][1]=='0'&&oxo[2][1]=='0'&&oxo[3][1]=='0')||
(oxo[1][2]=='0'&&oxo[2][2]=='0'&&oxo[3][2]=='0')||
(oxo[1][3]=='0'&&oxo[2][3]=='0'&&oxo[3][3]=='0')||
(oxo[1][1]=='0'&&oxo[2][2]=='0'&&oxo[3][3]=='0')||
(oxo[3][1]=='0'&&oxo[2][2]=='0'&&oxo[1][3]=='0'))
{
printf("\n GAME OVER...%s WINS.... GAME OVER\n",name1); /*if 0 wins print this*/
return; /*if '0' wins end game*/
}
else /*if 0 not won program continues*/
count<9;
if (count<9)
{
do{
printf("%s enter you next move, 'X's\n",name2); /*asks for m move by name*/
scanf("%d%d",&rx,&cx);
system ("clear");
}
while((oxo[rx][cx]!='-')||(oxo[rx][cx]=='X')||(oxo[rx][cx]=='0'));
{
oxo[rx][cx]='X';
}
count++;
}
display_grid();
/*These lines look to see if there is a row of Xs in any of the 8 ways possible program looks to see if Xs have won*/
if ((oxo[1][1]=='X'&&oxo[1][2]=='X'&&oxo[1][3]=='X')||
(oxo[2][1]=='X'&&oxo[2][2]=='X'&&oxo[2][3]=='X')||
(oxo[3][1]=='X'&&oxo[3][2]=='X'&&oxo[3][3]=='X')||
(oxo[1][1]=='X'&&oxo[2][1]=='X'&&oxo[3][1]=='X')||
(oxo[1][2]=='X'&&oxo[2][2]=='X'&&oxo[3][2]=='X')||
(oxo[1][3]=='X'&&oxo[2][3]=='X'&&oxo[3][3]=='X')||
(oxo[1][1]=='X'&&oxo[2][2]=='X'&&oxo[3][3]=='X')||
(oxo[3][1]=='X'&&oxo[2][2]=='X'&&oxo[1][3]=='X'))
{
printf("\nGAME OVER...%s WINS!!... GAME OVER\n",name2);
/*if X wins print this*/
return; /*if X wins end game*/
}
else /*if 0 not won program continues*/
count<9;
}
if (count=9) /*when 9 moves have been made with no winner game stops*/
system ("clear");
printf("\nGAME OVER...NO WINNER!!...GAME OVER\n"); /*print information telling users out*/
return 0;
}
void display_grid()
{
int row, col;
for(row=1;row<=3;row++)
{
for(col=1;col<=3;col++)
{
printf(" %c |",oxo[row][col]); /*prints & spaces vertical g grid lines*/
}
printf("\n");
if(row<=3)
{
printf(" ---------------\n"); /*prints & spaces horizontal g grid lines*/
}
}
return;
}