1

I am having trouble with creating an array of arrays. Here is my code for the program:

const unsigned char one[] PROGMEM = {

};

const unsigned char two[] PROGMEM = {

};
const unsigned char three[] PROGMEM = {

};
const unsigned char four[] PROGMEM = {

};
const unsigned char five[] PROGMEM = {

};
const unsigned char six[] PROGMEM = {

};
const unsigned char seven[] PROGMEM = {

};
const unsigned char eight[] PROGMEM = {

};
const unsigned char nine[] PROGMEM = {

};

const unsigned char array[] PROGMEM = {const unsigned char one[],const     unsigned char two[],const unsigned char three[],const unsigned char four[],const unsigned char five[],const unsigned char six[],const unsigned char seven[],const unsigned char eight[],const unsigned char nine[]};

Also in my void setup for another function:

const void make(int x, int y,const unsigned char array[], 67,67){

It is giving me weird errors such as:

Mattplztestit:17: error: expected identifier before numeric constant
Mattplztestit:17: error: expected ',' or '...' before numeric constant
Mattplztestit:178: error: expected identifier before numeric constant
Mattplztestit:178: error: expected ',' or '...' before numeric constant
Mattplztestit.ino: In function 'const void make(int, int, const unsigned char*, int)':
Mattplztestit:179: error: expected initializer before '<=' token
Mattplztestit:179: error: expected ';' before '<=' token
Mattplztestit:179: error: expected primary-expression before '<=' token
Mattplztestit.ino: In function 'void constr(int)':
Mattplztestit:193: error: too many arguments to function 'const void make(int, int, const unsigned char*, int)'
Mattplztestit.ino:178:12: note: declared here
Mattplztestit:194: error: expected ';' before '}' token

expected identifier before numeric constant

Can anybody please help?

Thankyou

2 Answers2

2

If you read a good beginners book it will tell you that arrays decays to pointers to their first element, which means you can have an array of pointers, and populate it with the pointers to the other arrays.

Something like

const unsigned char* array[] PROGMEM = {
    one,
    two,
    // And so on...
};
Community
  • 1
  • 1
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Hi, I tried using your solution however it is giving me this error: Mattplztestit:141: error: variable 'array' must be const in order to be put into read-only section by means of '__attribute__((progmem))' variable 'array' must be const in order to be put into read-only section by means of '__attribute__((progmem))' –  Aug 28 '16 at 18:00
  • 1
    It's also perfectly legal to define a two-dimensional array (which is simply an array of arrays). All the rows have to be of the same length. As for the error message, changing `const unsigned char *array[]` to `const unsigned char *const[]` should correct it. – Keith Thompson Aug 28 '16 at 19:32
0

You should change const unsigned char array[] To const unsigned char