2d Array Issues

I'm working with SDL...but this issue/question doesn't need knowledge of it.

I'm working on a tetris game with a 2d array that contains bool values of whether or not there is a block in that location.

The array is 20 x 10. (20 high and 10 wide)

I initialize all the variables to false using this

1
2
3
4
5
for (int i = 0; i < 20; i++)
{
     for (int j = 0; j < 10; j++)
	   (blockLocations[i][j] = false);
}


I'm using visual studio and looking at the debugger it displays


arrayA[20]	0x0022e61c {true (204), true (204), true (204), true (204), true (204), true (204), true (204), true (204), ...}	bool[10]



However, since it's an array shouldn't it not contain any values? (As the numbering system is 0,1,2,3,4...)
iirc correctly, some compilers will supply variables with default values, if thats what you are asking (why the array has default values). arrays are just like variables (well, mostly) except the can hold more than one value
UOfMichDeveloper wrote:
However, since it's an array shouldn't it not contain any values?

What does this mean? How can an area of memory not have a value?
I defined the array to have 20 rows. And the numbering system for arrays is (0...19) so why are values displayed at array[20]?
oh i see what you mean. hes asking why it says arrayA[20] at the beginning of the debugger output. this ends my help since ive never used that one before
However, since it's an array shouldn't it not contain any values? (As the numbering system is 0,1,2,3,4...)


I defined the array to have 20 rows. And the numbering system for arrays is (0...19) so why are values displayed at array[20]?


What...? What are you asking? Where are you setting your breakpoint?
Last edited on
Topic archived. No new replies allowed.