Hey guys, I just learned the very basics of arrays and I have to write this program of a tic-tac-toe game. The requirements are this:
Write a modular program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with 3 rows and 3 columns as the game board. Each element of the array should be initialized with an asterisk(*). The program should display the initial board configuration and then start a loop that does the following:
Allow player 1 to select a location on the board for an X by entering a row and column number. Then redisplay the board with an X replacing the * in the chosen location
If there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an O by entering a row and column number. Then redisplay the board with an O replacing the * in the chosen location.
The Loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie has occurred.
Player 1 wins when there are three Xs in a row, a column, or diagonal on the game board
Player 2 wins when there are three Os in a row, a column, or diagonal on the game board
A tie occurs when all locations on the board are full, but there is no winner.
Input Validation: Only allow legal moves to be entered. The row must be 1, 2, or 3. The column must be 1, 2, or 3. The(row,column) position entered must currently be empty(i.e., still have an asterisk in it).
Okay, that is all. My problem is that I barely know how to use arrays. So what I was thinking is that maybe I should make an array as a function and in that function, make a loop for when I call it in my main function. That is where I am starting to get at. Are there any suggestions as to how else I can start this program? I just need guidance, not the code itself. I want to make the code myself, but I feel like I will need help. Any suggestion will be appreciated. Thank you.