在新数组中存储字符数组地址

Store char arrays address in new array

我在 Arduino 程序中有一个包含文件。单片机是ESP32.

包含的文件是:

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};

当我编译代码时,返回了这个错误:

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

请帮助我。如何将 char 数组地址存储在另一个数组中。

这是正确的:

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 };
  • 你需要 unsigned char 因为你的值 > 127
  • 您需要删除 &s,bitmap_1587 等已经是地址
  • 你需要 const char* char_addr[] 因为你有 const 用于 bitmap_... 数组。