To really beat the dead horse, and reiterate what Thomas says:
If you make an array of size "n", the elements are numbered from zero to n-1.
If you make an array of size 3, the elements are numbered 0, 1, 2.
If you make an array of size 3, there IS NO element 3.
1 2 3 4 5
|
int array[3]; // a new array, of size three
array[0]; // This exists
array[1]; // This exists
array[2]; // This exists
array[3]; // This does NOT exist
|
By the nature of C++ trusting you to know what you're doing, if you try to read or write array elements that don't exist, it will instead read/write memory next to the array. That memory could contain other variables that you're trashing, or that will just overwrite whatever you just wrote. That memory could be outside your allotted memory space and the program could crash.
In a 2D array, that other memory could be in use by other parts of the 2D array, so you'll be trashing your own array.
So let's look at your code.
int array [9][9];
Right, so
array[0][0]
to
array[8][8]
exist.
array[4][9] = 0;
DOES NOT EXIST
array2[9][0] = 0;
DOES NOT EXIST
and so on.