Below is my MRE. Essentially, I am making a board game, and I need to do two things. Make the board, and after each turn, print it. Since the board changes after each turn, I have them in two separate functions makeBoard
and printBoard
below, I just put them in the MRE. The board also gets its dimensions from args
and so it can be any size that the player chooses. But when I print out the empty board, it says the error mentioned above.
for context the matrix is supposed to be a 5 by 5 then it should print like this:
. . . . . . . . . . . . . . . . . . . . . . . . .
edit: I can not test if the matrix prints with the correct formatting since I am getting this error, so if there are issues with that part of the code, I will take care of them later.
int main()
{
int x = 5;
int y = 5;
char board[5][5];
// this is where I am filling the board with its 'null' values
for(int i =0; i<x; i++){
for(int j =0; j<y; j++){
// this is where the error takes place
board[i][j]= ".";
}
}
// this is where I am printing the board, I have a specific format so,
// that there is a space between each dot
for(int i=0; i<x; i++){
for(int j = 0; j<y; j++){
if(j<y-1){
printf("%c",board[i][j]);
printf(" ");
}
else if(j=y-1){
printf("%c", board[i][j]);
}
printf("\n");
}
}
}