1 #include 2 3 int main() 4 { 5 int gridNums[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}}; //Array to...
Question:
1 #include
2
3 int main()
4 {
5 int gridNums[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}}; //Array to show the>
6 char board[3][3]; //Array to save X & O placements as the game progre>
7 int player1 = 0; //Track player 1's wins
8 int player2 = 0; //Track player 2's wins
9 char input; //User input
10
11 //Fill board array with dashes
12
13
14 printf("-----------------------\n");
15 printf("---- Tic-Tac-Toe ----\n");
16 printf("-----------------------\n");
17 //Print the grid numbers before the game starts (call function)
18 ////Only print once at the beginning of each game
19
20
Using the provided skeleton code, write the Tic-Tac-Toe program described below, using c programming please .
Fill board array with dashes ( - ) as placeholders to represent empty spots on the board.
Prompt “Player 1” (O) to choose a spot on the board.
Fill that spot in the corresponding index of the board array.
Print the updated board to the screen using the function.
Prompt “Player 2” (X) to choose a spot on the board.
Fill that spot in the corresponding index of the board array.
Print the updated board to the screen using the function.
Players should be prompted until there is a winner.
Track the amount of wins each player has.
Ask the players if they would like to play again.
If they want to play again…
Clear the screen before starting another game.
Print the grid numbers so that the users know which number to enter to choose their spot.
If they do not want to play again…
Print their scores into a text file called “scores.txt”
Use a print statement to inform the players where they can view their scores.
Program should include the following functions:
printBoard() – print the tic-tac-toe board
checkWin() – check to see which player won the game (if any)
saveScore() – save the score of both players to a text file named “scores.txt”
In total, you will write 3 files:
main.c – contains your main function
functions.c -contains all functions other than main
header.h – custom header file