Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++;访问定义宏数据 我有一个C++头文件,它有这样的定义……/P>_C++ - Fatal编程技术网

C++;访问定义宏数据 我有一个C++头文件,它有这样的定义……/P>

C++;访问定义宏数据 我有一个C++头文件,它有这样的定义……/P>,c++,C++,#定义温度{0x04,0x06,0xAA,0xBF…} 比如说?假设我想捕获单个字节 如何将名为x的uint8\t类型的变量分配给临时结构中的第三个字节 uint8_t x=TEMP[2]?宏只需在编译时粘贴到源代码中即可 所以,你可以这样做: char tmp[] = TEMP; // which expands to 'char tmp[] = {0x04, 0x06, ...}' 然后使用它,就像使用普通数组一样。宏只需在编译时粘贴到源代码中即可 所以,你可以这样做: char tmp

#定义温度{0x04,0x06,0xAA,0xBF…}

<如何访问我的C++程序中的数据?< /P> 比如说?假设我想捕获单个字节

如何将名为
x
uint8\t
类型的变量分配给临时结构中的第三个字节


uint8_t x=TEMP[2]

宏只需在编译时粘贴到源代码中即可

所以,你可以这样做:

char tmp[] = TEMP; // which expands to 'char tmp[] = {0x04, 0x06, ...}'

然后使用它,就像使用普通数组一样。

宏只需在编译时粘贴到源代码中即可

所以,你可以这样做:

char tmp[] = TEMP; // which expands to 'char tmp[] = {0x04, 0x06, ...}'

然后处理它,就像处理普通数组一样。

保持这样的数组

uint8_t temp[] = TEMP;
uint8_t x = temp[2];
这将扩展到

uint8_t temp = {0x04,0x06,0xAA,0xBF};
然后可以像这样访问第三个值

uint8_t temp[] = TEMP;
uint8_t x = temp[2];

保持这样的数组

uint8_t temp[] = TEMP;
uint8_t x = temp[2];
这将扩展到

uint8_t temp = {0x04,0x06,0xAA,0xBF};
然后可以像这样访问第三个值

uint8_t temp[] = TEMP;
uint8_t x = temp[2];

uint8_t x=std::vector(TEMP)[2]工作但不雅观。

uint8\u t x=std::vector(TEMP)[2]有效,但不雅观。

您编写了代码吗?你犯了什么错误?那不是数据。只发短信。不清楚您的问题是什么,请澄清!你把它编码了吗?你犯了什么错误?那不是数据。只发短信。不清楚您的问题是什么,请澄清!