xcode - Imnitializing a prmitive array - corrupting other arrays -


i using primitive array type in xcode. example:

int matrix [10][10]; 

i using simple loop initialise array

for(int x=0;x<=10;x++)   for(int y=0;y<=1;0y++)      matrix[x][y] = 0; 

i initialize sevreal matrices in manner throughout code. noticed @ times after initialization performed, array prviously initialized or updated contains garbage. there simpler way initialize array of type. and/or why seem corrupt other arrays.

your array has 10 positions in both dimensions, loops go eleven.

try

for(int x = 0; x < 10; x++)   for(int y = 0; y < 10; y++)      matrix[x][y] = 0; 

notice use of lesser than comparator instead of lesser or equal to.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -