Initialize the Board
Learn what components are required for initializing the board.
We'll cover the following
What we have
We have the breakdown of the game, so let’s go through the first thing we saw in the game.
We have to initialize a board for our game. A Tic-Tac-Toe board has 9 empty places, so we need an array of the same length.
Requirements of this module
We need to place X and O on our game board. These are char
type inputs, so our array will be char
type.
Now, we know that we need a char
type array of length 9. We can perform these steps to complete this task:
-
Receive two parameters:
board
and itssize
. -
Fill the array using the
for
loop with the characters “1” to “9”.
Let’s try it
All the functions are already defined. You just have to implement the given function and execute the code.
Get hands-on with 1400+ tech skills courses.