Search code examples
c++carduinoesp32arduino-esp32

Store char arrays address in new array


I have an included file in an Arduino program. MCU is ESP32.

included file is:

const char bitmap_1587[] PROGMEM = {248,254,254,230,241,231,247,199};
const char bitmap_1604[] PROGMEM = {249,254,254,254,0,191};
const char bitmap_1575[] PROGMEM = {7};
const char* char_addr[] = {&bitmap_1587,&bitmap_1604,&bitmap_1575};

When i compile the code, this error is returned:

cannot convert 'const char (*)[6] to 'char*' in initialization

cannot convert 'const char (*)[6]' to 'char*' in initialization

cannot convert 'const char (*)[1]' to 'char*' in initialization

Please help me. How can i store char array address in an other array.


Solution

  • This would be correct:

    const unsigned char bitmap_1587[] PROGMEM = { 248,254,254,230,241,231,247,199 };
    const unsigned char bitmap_1604[] PROGMEM = { 249,254,254,254,0,191 };
    const unsigned char bitmap_1575[] PROGMEM = { 7 };
    const unsigned char* char_addr[] = { bitmap_1587,bitmap_1604,bitmap_1575,bitmap_1605,bitmap_32,bitmap_97,bitmap_98,bitmap_99,bitmap_1777,bitmap_1778,bitmap_1779 };
    
    • you need unsigned char because you have values > 127
    • you need to remove the &s, bitmap_1587 etc. are already addresses
    • you need const char* char_addr[] because you have const for the bitmap_... arrays.