0

For example I have these ints value.

int map1[10][10] = //;
int map2[10][10] = //;
int map3[10][10] = //;
int map4[10][10] = //;
int map5[10][10] = //;

for (int i = 1 ; i < 6 ; i++)
map{i}[2][2] = 3;

The above code just for illustration/understanding, I know it is wrong. How can I select/access my ints ?

Alberto Bonsanto
  • 17,556
  • 10
  • 64
  • 93
Moonlight
  • 37
  • 1
  • 5

1 Answers1

8

You are declaring a 2D array or an array of arrays filled with integers numbers int map5[10][10], so to access those values you need to use this syntax, e.g. map5[0][1] refers to the second element in the first row.

__________________________________enter image description here

________________________________________enter image description here

If you want to easily use the different arrays, use a multiple subscripted array or a 3D array, but there are many other ways.

int map[5][10][10] = //;

for ( int i = 0; i < 5; i++ )
    map[ i ][ 2 ][ 2 ] = 3;
Alberto Bonsanto
  • 17,556
  • 10
  • 64
  • 93