Hi, thanks for looking at this.
Here is what i have so far:
Code:
int printBoard(int x, int y, char array)
{
int x; //row
int y; //column
char board[3][3]; /* declares an array for the gameboard */
for ( x = 0; x < 3; x++ ) {
for ( y = 0; y < 3; y++ )
board[x][y] = '-'; /* Set each element to a dash */
}
printf( "Tic-Tac-Toe board:\n" );
for ( x = 0; x < 3;x++ ) {
for ( y = 0; y < 3; y++ )
{
printf( "%c",board[x][y] );
}
}
}
So this basically prints a 3 x 3 matrix with '-' in each position. One question is how can i return the output to my main function? can i say
Code:
return printf( "%c",board[x][y] );
I also need help understanding how to use a function like this and some how incorporating this function:
Code:
int userMove() {
a = scanf("%d%d");
i = a / 10;
j = a%10;
board[i][j] = 'x'; //user is an X
}
So this just assigns an 'x' to a user specified location in the 3x3 matrix. I can't get my mind around how to save this into the printBoard function. It continues to print out a 3x3 matrix full of dashes but when the user inputs the first 'X' how do i tell the function to exclude that certain position and instead print the 'x'. Any help understanding this would be great.