// This program will start to implement tictactoe - don't worry // we will still keep it simple in this lecture. Today, we will // - draw the 3x3 grid // - ask player one to make a move // - ask player two to make a move // We will not check for win conditions or loop through asking them // to keep playing, to start with today it is a simple exercise in // visualising 2D arrays and structs and placing something into them. // Week 4 Lecture 8 #include #include #define SIZE 3 struct player { int x; int y; char name[20]; }; //void print_grid(char grid[SIZE][SIZE]); //void initialise_grid(char grid[SIZE][SIZE]); //int check_input(int x, int y); int main(void) { struct player player1; struct player player2; char grid[SIZE][SIZE]; printf("Player 1, enter your name: "); // remember that fgets stops reading and taking things into its buffer // if n-1 chars are read, if a newline is pressed, if EOF is reached // (indicated by NULL) printf("%s, Please enter position x y: ", ); scanf("%d %d", ); printf("Player 2, enter your name: "); // remember that fgets stops reading and taking things into its buffer // if n-1 chars are read, if a newline is pressed, if EOF is reached // (indicated by NULL) fgets(player2.name, 20, stdin); printf("%s, Please enter position x y: ", ); scanf("%d %d", ); initialise_grid(grid); print_grid(grid); return 0; } // Function to initialise the grid (assign values in 2D array) void initialise_grid(char grid[SIZE][SIZE]) { } // Function to print the grid void print_grid(char grid[SIZE][SIZE]) { printf("\n_ _ _ _ _ _ _ _\n\n"); for(int i = 0; i < SIZE; i++) { for(int j = 0; j < SIZE; j++) { printf("%c", grid[i][j]); if (j < 2) { printf(" | "); } } if (i < 2) { printf("\n_ _ _ _ _ _ _ _\n"); } printf("\n"); } printf("_ _ _ _ _ _ _ _\n\n"); } // Function to check that input is on the grid int check_input(int x, int y) { }