I'm trying to use a multi-dimensional array to store data, however, some of the indexes of the array don't seem to be working right. I get correct data for most of the elements but a portion of them will all read zero even though the values that were read in are not zero. The array ends up looking something like this:
-3.238467 -3.237679 -0.487128 -3.237634 -3.238513 -3.239868
-3.239361 -3.238660 0.000000 -3.238610 -3.435949 -3.437109
-3.622402 -3.621796 0.000000 -3.621911 -3.436662 -3.437587
-3.237072 -3.236771 0.000000 -3.237329 -3.237926 -3.238605
-3.227221 -3.227291 0.000000 -3.228477 -3.229173 -3.229775
-3.204790 -3.205429 0.000000 -3.207087 -3.207956 -3.208255
-2.618961 -2.621088 -2.622552 -2.623831 -2.624973 -2.625057
Even if I check the values like this:
for(j=0; j<(num_cell_y); j++) {
for(i=0; i<(num_cell_x); i++) {
...
...
...
grid[i][j] = u_avg;
printf("%f\n", u_avg);
printf("%f\n", grid[i][j]);
}
}
I get two different values printed out:
-3.237675
0.000000
Has anyone else had this happen to them or know of something I may have missed that is causing this?