/* tic-tac-toe project.*/ #include void playerturn(char *, char **); void move(char *); int main() { char table[3][3]; char input; int x; for(x = 0;x <= 2; x++) { int y; for(y = 0; y <= 2; y++) { table[x][y] = ' '; } } printf("_%c_|_%c_|_%c_\n_%c_|_%c_|_%c_\n %c | %c | %c\n", table[0][0], table[1][0], table[2][0], table[0][1], table[1][1], table[2][1], table[0][2], table[1][2], table[2][2]); while(input != 'q') { playerturn(&input, table); } return 0; } void playerturn(char *input, char **table) { *input = getchar(); switch(*input) { case 1: move(&table[1][3]); break; case 2: move(&table[2][3]); break; case 3: move(&table[3][3]); break; case 4: move(&table[1][2]); break; case 5: move(&table[2][2]); break; case 6: move(&table[3][2]); break; case 7: move(&table[1][1]); break; case 8: move(&table[2][1]); break; case 9: move(&table[3][1]); break; default: printf("Bad move, try a number from 1 to 9.\n"); playerturn(&input, table); break; } } void move(char *table) { *table = 'X'; }