I'm currently working on a Tic Tac Toe game that will be interactive for a user. I think I have it all working, I just can't figure out how to get the displayBoard() function to print out the current state of the board so that the user knows which spaces are open and which spaces are not. How can I get the displayBoard() function to print to the screen?
My code is as follows:
#include <stdio.h>
void initializeBoard(char board[][3]);
void displayBoard(char board[][3]);
void makeMove(char board[][3], int player);
int main(void)
{
char board[3][3];
int row;
int column;
int move = 1;
int player = 1;
initializeBoard(board);
while (move > 10)
{
displayBoard(board);
makeMove(board, player);
move++;
if (move == 2 || move == 4 || move == 6 || move == 8)
{
player = 2;
}//close of if
else
{
player = 1;
}//close of else
}
}//close of main function
void initializeBoard(char board[][3])
{
int i = 0;
int j = 0;
while (i < 4)
{
while (j < 4)
{
board[i][j] = ' ';
j++;
}//close of while loop
j = 0;
i++;
}//close of while loop
}//close of initializeBoard
void displayBoard(char board[][3])
{
printf(" 1 2 3");
printf("1 [%c] [%c] [%c]", board[1][1],board[1][2],board[1][3]);
printf("2 [%c] [%c] [%c]", board[2][1],board[2][2],board[2][3]);
printf("3 [%c] [%c] [%c]", board[3][1],board[3][2],board[3][3]);
}//close of displayBoard
void makeMove(char board[][3], int player)
{
int row;
int column;
printf("Enter the row and column you'd like to fill:");
scanf("%d %d", &row, &column);
if (player == 1)
{
board[row][column] = 'X';
}//close of if
else
{
board[row][column] = 'O';
}//close of else
}//close of makeMove
while (i < 4) { while (j < 4)-->< 3scanf("%d %d", &row, &column);checkscanf()return value and the values ofrow, columnbefore proceeding.