Code:
#include <stdio.h>
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0;
int update(int player);
int print_chart(int a, int b, int c, int d, int e, int f, int g, int h, int i);
int main()
{
int scoreX, scoreY;
scoreX = 0;
scoreY = 0;
printf(" a | b | c\n");
printf("---+---+---\n");
printf(" d | e | f\n");
printf("---+---+---\n");
printf(" g | h | i\n\n");
printf("+-----------+\n");
update(1);
print_chart(a,b,c,d,e,f,g,h,i);
update(2);
print_chart(a,b,c,d,e,f,g,h,i);
update(1);
print_chart(a,b,c,d,e,f,g,h,i);
update(2);
print_chart(a,b,c,d,e,f,g,h,i);
return 0;
}
int print_chart(int a, int b, int c, int d, int e, int f, int g, int h, int i)
{
printf("+-----------+\n\n");
printf(" %d | %d | %d\n",a,b,c);
printf("---+---+---\n");
printf(" %d | %d | %d\n",d,e,f);
printf("---+---+---\n");
printf(" %d | %d | %d\n\n",g,h,i);
printf("+-----------+\n\n\n");
return 0;
}
int update(int player)
{
char choice;
printf("Player%d [%d] choose: ",player,player);
scanf("%s",&choice);
if(choice == 'a')
return a = player;
else if(choice == 'b')
return b = player;
else if(choice == 'c')
return c = player;
else if(choice == 'd')
return d = player;
else if(choice == 'e')
return e = player;
else if(choice == 'f')
return f = player;
else if(choice == 'g')
return g = player;
else if(choice == 'h')
return h = player;
else if(choice == 'i')
return i = player;
else
return 0;
return 0;
}
works fine...