我有几个 450 元素的字符数组(存储位图数据以显示在 lcd 屏幕上。)我想将它们放在头文件下并 #define
它们,但我不断遇到编译错误。我如何在 C 中执行此操作?
#define numbers[450] {0, 1,etc...}
#define 数字 {0、1 等...}
#define numbers[450]
稍后设置数字
还有很多...
最佳答案
嗯……你当然不需要使用定义。只需将它们作为 const 静态数组添加到 header 中即可。
/* prevents multiple, redundant includes */
/* make sure to use a symbol that is fairly sure to be unique */
#ifndef TEST_H
#define TEST_H
/* your image data */
const char image[] = { 1, 2, 3, 4, ... };
#endif
此外,如果您需要有关编译错误的帮助,那么您应该发布您的代码。
关于c - 在 C 中定义数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9846920/