I'm having an issue where an array is not being initialized and it is referencing the memory space of another array.
I have a 3d array and a 2d array with two different names. I have nested for loops to set their values 0 and -1 initially. After the first 3d array is set to 0, when i go to initialize the second 2d array values to -1 it replaces the first array's values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int a [n][n];
int b [n][n][m];
for (int i= 1; i < (n+1); i++) {
for (int j= 1; j < (n+1); j++) {
for (int k= 0; k < m; k++) {
a[i][j][k] = 0;
}
}
}
...
<some code not relating to either a or b or n or m>
...
for (int i = 1; i < (n+1); i++) {
for (int j = 1; j < (n+1); j++) {
b[i][j] = -1;
}
}