It's been awhile since I've worked with C, and I was playing around with some basic code to refresh, and I'm getting a weird result.
I've initialized a 2d array of dxd - let's say d = 4. Then using the following code, I just print it out, but do not want to print the bottom right corner.
Code:
for(int i = 0; i < d; i++) {
for(int j = 0; j < d; j++) {
if (i != (d - 1) && j != (d - 1)) {
// printf("(i = %i and j = %i)", i, j);
printf("%i ", board[i][j]);
}
}
printf("\n");
}
So instead of print out something like this:
15 14 13 12
11 10 9 8
7 6 5 4
3 1 2 _
I'm getting this:
15 14 13
11 10 9
7 6 5
I've looked over the loop several times and it seems correct. Am I wrong here?