Guys,
is there anything stopping me from doing something like that described below
int size = 100;
BYTE *bits;
BYTE *map;
int x = 0;
int y = 0;
bits = new BYTE[ size ];
map = new BYTE [ 10, 10 ];
//Assume that I randomly fill the bits array with random numbers from 0 to
255 here
for (int i = 0; i < size; i++)
{
x = (i % size);
y = (i / size);
map[ x, y] = bits [i];
if ((map[ x,y ] < 10) && (map[( x-1),y] < 10))
{
//do something;
}
}
The problem I am having is whenever I test the value of map[(x-1),y) inside
the for loop, it always gives me the current value of map[x,y].
I have checked by setting breakpoints, writing the values to the debug
window etc and it confirms this. However, if I test any value of map[x,y]
outside the loop, I get the correct answer.
e.g suppose the iterating through the for loop, x = 5 and y = 2 and the
value at this point was 0 and the value at x = 4, y = 2 was 255,
I would get:
map[5,2] = 0 //which is correct
map[4,2] = 0 //it should be 255.
If I write out the values of map[] after the loop has finished, I get the
expected results.
This isn't a complete listing, I have done error checking etc to make sure
the coordinates aren't out of bounds etc.
If it makes any difference, this loop is in a WM_PAINT event, the program
compiles & runs under debug & release, I just don't get the expected
results, I'm using vc++ 2008 express.
I would appreciate any help.