Imnitializing a prmitive array - corrupting other arrays
I am using primitive array type in xcode. Example:
int matrix ;
I am also using a simple loop to initialise the array
for(int x=0;x<=10;x++) for(int y=0;y<=1;0y++) matrix[x][y] = 0;
I initialize sevreal matrices in this manner throughout the code. I noticed at times after the initialization is performed, an array that was prviously initialized or updated now contains garbage. Is there a simpler way to initialize an array of this type. And/Or why does this seem to corrupt other arrays.
Your array has 10 positions in both dimensions, but your loops go up to eleven.
for(int x = 0; x < 10; x++) for(int y = 0; y < 10; y++) matrix[x][y] = 0;
Notice the use of the lesser than comparator instead of lesser than or equal to.