Multi-dimensional arrays

Hi,

I’m trying to set up a three-dimensional array like this:

byte pattern[][16][2] = {{B00000001,B10000000},
                     {B00000011,B11000000},
                     {B00000111,B11100000},
                     {B00001111,B11110000},
                     {B00011111,B11111000},
                     {B00111111,B11111100},
                     {B01111111,B11111110},
                     {B11111111,B11111111},
                     {B11111110,B01111111},
                     {B11111100,B00111111},
                     {B11111000,B00011111},
                     {B11110000,B00001111},
                     {B11100000,B00000111},
                     {B11000000,B00000011},
                     {B10000000,B00000001},
                     {B00000000,B00000000}},
                     
                     {{B00010001,B10001000},
                     {B00110011,B11001100},
                     {B01110111,B11101110},
                     {B11111111,B11111111},
                     {B11101110,B01110111},
                     {B11001100,B00110011},
                     {B10001000,B00010001},
                     {B00000000,B00000000},
                     {B00010001,B10001000},
                     {B00110011,B11001100},
                     {B01110111,B11101110},
                     {B11111111,B11111111},
                     {B11101110,B01110111},
                     {B11001100,B00110011},
                     {B10001000,B00010001},
                     {B00000000,B00000000}};

When I try to compile, I get the following error on the first line of the second block of values:

error: expected unqualified-id before '{' token

Does anyone know what might be causing this?

Thanks

I haven't counted the brackets, but that looks like a two dimensional array to me.

Ah, I might be missing something then.

I was trying to declare an array that has two values, sixteen times, many times.

byte pattern[][16][2]

Is that not the way to do it?

Thanks

I think you don't have enough braces, surround all that with another set.

byte pattern[][16][2] = 
{                   
                    {{B00000001,B10000000},
                     {B00000011,B11000000},
                     {B00000111,B11100000},
                     {B00001111,B11110000},
                     {B00011111,B11111000},
                     {B00111111,B11111100},
                     {B01111111,B11111110},
                     {B11111111,B11111111},
                     {B11111110,B01111111},
                     {B11111100,B00111111},
                     {B11111000,B00011111},
                     {B11110000,B00001111},
                     {B11100000,B00000111},
                     {B11000000,B00000011},
                     {B10000000,B00000001},
                     {B00000000,B00000000}},
                     
                     {{B00010001,B10001000},
                     {B00110011,B11001100},
                     {B01110111,B11101110},
                     {B11111111,B11111111},
                     {B11101110,B01110111},
                     {B11001100,B00110011},
                     {B10001000,B00010001},
                     {B00000000,B00000000},
                     {B00010001,B10001000},
                     {B00110011,B11001100},
                     {B01110111,B11101110},
                     {B11111111,B11111111},
                     {B11101110,B01110111},
                     {B11001100,B00110011},
                     {B10001000,B00010001},
                     {B00000000,B00000000}}
};

That compiles, don't know if it's correct though.


Rob

Ah, thankyou! That works perfectly.

Thanks again.