I am trying to create 8x8 array, but when I am printing that array, after [7][7] Element I am not getting the exact values that I assigned while creating the array. My array is a follows
#include <stdio.h>
int main() {
int puzzle[8][8] = {
// 0 1 2 3 4 5 6 7 8
{0,0,2,0,4,0,5,9,3},//0
{7,0,0,3,1,0,4,0,8},//1
{4,0,0,8,0,5,1,0,2},//2
{8,3,0,2,0,0,0,0,0},//3
{0,9,6,0,0,0,3,5,0},//4
{0,0,0,0,0,4,0,8,6},//5
{3,0,1,5,0,9,0,0,7},//6
{6,0,5,0,2,8,0,0,1},//7
{0,4,0,0,7,0,6,0,0} //8
};
for (int i = 0; i < 9; ++i)
{
for (int j = 0; j < 9; ++j)
{
printf("\n puzzle[%d][%d] = %d",i,j,puzzle[i][j]);
}
}
return 0;
}
and I am getting output as
puzzle[0][0] = 0
puzzle[0][1] = 0
puzzle[0][2] = 2
puzzle[0][3] = 0
puzzle[0][4] = 4
puzzle[0][5] = 0
puzzle[0][6] = 5
puzzle[0][7] = 9
puzzle[0][8] = 7
puzzle[1][0] = 7
puzzle[1][1] = 0
puzzle[1][2] = 0
puzzle[1][3] = 3
puzzle[1][4] = 1
puzzle[1][5] = 0
puzzle[1][6] = 4
puzzle[1][7] = 0
puzzle[1][8] = 4
puzzle[2][0] = 4
puzzle[2][1] = 0
puzzle[2][2] = 0
puzzle[2][3] = 8
puzzle[2][4] = 0
puzzle[2][5] = 5
puzzle[2][6] = 1
puzzle[2][7] = 0
puzzle[2][8] = 8
puzzle[3][0] = 8
puzzle[3][1] = 3
puzzle[3][2] = 0
puzzle[3][3] = 2
puzzle[3][4] = 0
puzzle[3][5] = 0
puzzle[3][6] = 0
puzzle[3][7] = 0
puzzle[3][8] = 0
puzzle[4][0] = 0
puzzle[4][1] = 9
puzzle[4][2] = 6
puzzle[4][3] = 0
puzzle[4][4] = 0
puzzle[4][5] = 0
puzzle[4][6] = 3
puzzle[4][7] = 5
puzzle[4][8] = 0
puzzle[5][0] = 0
puzzle[5][1] = 0
puzzle[5][2] = 0
puzzle[5][3] = 0
puzzle[5][4] = 0
puzzle[5][5] = 4
puzzle[5][6] = 0
puzzle[5][7] = 8
puzzle[5][8] = 3
puzzle[6][0] = 3
puzzle[6][1] = 0
puzzle[6][2] = 1
puzzle[6][3] = 5
puzzle[6][4] = 0
puzzle[6][5] = 9
puzzle[6][6] = 0
puzzle[6][7] = 0
puzzle[6][8] = 6
puzzle[7][0] = 6
puzzle[7][1] = 0
puzzle[7][2] = 5
puzzle[7][3] = 0
puzzle[7][4] = 2
puzzle[7][5] = 8
puzzle[7][6] = 0
puzzle[7][7] = 0
puzzle[7][8] = -445142480
puzzle[8][0] = -445142480
puzzle[8][1] = 32765
puzzle[8][2] = 480800256
puzzle[8][3] = -129200335
puzzle[8][4] = 0
puzzle[8][5] = 0
puzzle[8][6] = -2108403533
puzzle[8][7] = 32522
puzzle[8][8] = -2106304992
As you can see I am not getting exact values that I assigned to [7][8]th position. The output I am getting looks like address or ids. I am not getting why it is happening, is it ide problem or is there any mistake in my code?
< 9should be< 8. Indexes go from 0 to 7.int puzzle[8][8]should beint puzzle[9][9]