I once had a matrix working like this
matrix[20][2]
So, since its indexed with 0, I used them as matrix[i][0] or matrix[i][1].
Then the other day, I forgot the 0 index, and used matrix[i][2].
And it worked perfectly fine! And worse so, the program didn't work anymore when I revert that back to matrix[i][1]. Also matrix[i][0] now had ridiculous values inside.
More importantly, there are other places in the code in which the matrix works with matrix[i][0 or 1]. THE SAME MATRIX.
Its just this particular segment that has gone haywire.
I am using mingw latest version, and no the matrices are not passed by reference to anything or anywhere. And they are all initialized to all 0 values by a loop at the start of the code. The matrices are double type.
My program is working fine, after about half an hour of randomly placing 0s, 1s and 2s somehow its working very fine. But I am afraid it would go bonkers again on another machine.
Does anyone know whats happening? Is it my compiler or my coding?
Thanks!
matrix[20][2]
So, since its indexed with 0, I used them as matrix[i][0] or matrix[i][1].
Then the other day, I forgot the 0 index, and used matrix[i][2].
And it worked perfectly fine! And worse so, the program didn't work anymore when I revert that back to matrix[i][1]. Also matrix[i][0] now had ridiculous values inside.
More importantly, there are other places in the code in which the matrix works with matrix[i][0 or 1]. THE SAME MATRIX.
Its just this particular segment that has gone haywire.
I am using mingw latest version, and no the matrices are not passed by reference to anything or anywhere. And they are all initialized to all 0 values by a loop at the start of the code. The matrices are double type.
My program is working fine, after about half an hour of randomly placing 0s, 1s and 2s somehow its working very fine. But I am afraid it would go bonkers again on another machine.
Does anyone know whats happening? Is it my compiler or my coding?
Thanks!
Comment