Hey, Im having trouble understanding how this function prints out this board. mainly how the 2d array is equal in 1 or 2 or 3 or 0.
Code:
void drawboard(int board[6][7]){
int i;
int j;
printf(" 1 2 3 4 5 6 7 \n");
for(i = 5; i >= 0; i = (i - 1))
{
for(j = 0; j < 7; j = (j + 1))
{
printf(" | ");
if(board[i][j] == 1)
{
printf("X");
}
else if(board[i][j] == 2)
{
printf("O");
}
else if(board[i][j] == 3)
{
printf("4");
}
else if(board[i][j] == 0);
{
printf(" ");
}
}
printf(" | \n");
}
printf(" ----------------------------- \n");
}
This function prints out a board for connect 4, and im trying to update it in a turn based way by calling it after I ask a user for what column he wants to drop the piece. So he can choose columns 1 throught 7.
So Im going to update my array to
board[]["whatever column he chose"]. I dont know what to do for the row.
And then the function will take the board and hopefully drop the piece