# Is it possible to have an array of int arrays?

I have a huge number of arrays, each with a series of numbers each referring to an LED on a strip. I want to be able to address each one by a number, so the logical solution to that for me was to make the whole thing into an array. Can that be done, or is there a better work around that can be implemented?

• Yes t is possible: you should take a look at cplusplus.com/doc/tutorial/arrays and search for "multidimensional arrays" there. – jfpoilpret May 6 '16 at 9:25
• My word, my mind is blown. Thanks for that @jfpoilpret. I'll see what I can do with that. – mr-matt May 6 '16 at 9:30
• I have question. What if wee have array a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; b[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; and then use another array to gather arrays before defining, za[] = {a[], b[]}; or `za[] = {a, b};` I try it before with led array, who another person defining letters as binary code, and I was trying update that code and use next array to store set of letters which will use defining arrays from rows with binary code. – maxim Jun 24 '18 at 17:56

Yes you can have arrays inside arrays.

The array would be declared as:

``````int arrayName [ x ][ y ];
``````

where `x` is the number of rows and `y` is the number of columns.

The example below declares and initializes a 2D array with 3 rows and 10 columns:

``````int myArray = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 },
{ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 } };
``````

To access the value of 27 (and save it into myValue):

``````myValue = myArray;
``````
• What if I want an array of pointers to arrays? – shinzou Feb 12 '18 at 19:05
• – sa_leinad Feb 13 '18 at 0:49
• It would be worth adding than this 2D array is actually an array of 3 arrays of 10 numbers. Not all programming languages use row-major order. – Edgar Bonet Jun 24 '18 at 19:22