Hello all,
I'm trying to print a tic tac toe board which needs the 2d array of user inputs. I keep getting "an array may not have elements of this type" under the braces of the array when I try to do the following:
Code:
char board[3][3] = { {' ',' ',' '},{' ',' ',' '},{' ',' ',' '} };
void printBoard(char board[][]);
which is trying to pass the array board to:
Code:
void printBoard(char board[][]){
printf(" %c | %c | &c \n", board[0][0], board[0][1], board[0][2]);
printf("---|---|---\n");
printf(" %c | %c | &c \n", board[1][0], board[1][1], board[1][2]);
printf("---|---|---\n");
printf(" %c | %c | &c \n\n", board[2][0], board[2][1], board[2][2]);
}
The assignment also said I could use a pointer
Code:
char *ptr = &board[0][0];
and I saw some uses of it on other websites, but I am unsure how to implement it other than checking which character ('X' or 'O') would be in whatever part of the array it's pointing to.
The prompt doesn't specify that I need to use another function for the game at all, but I would prefer to have neater code using multiple functions rather than write everything in main.
Thanks!