[英]How assign #define with unsigned char
I want to know can assign #define
with unsigned char
??if can how??我想知道可以用
unsigned char
分配#define
??如果可以如何??
for example:例如:
#define ACCESS_PSS {0x32,0xFD,0x6E,0x2D}
int main(){
unsigned char ResponseData[100];
for (int i = 0; i <4;i++0){
if (ResponseData[i+5]==ACCESS_PSS){ //how to do this???
cout<<5<<endl;
}
ResponseData
from programm get value and byte 5 ta 8 is equal with ACCESS_PSS
ResponseData
from programm get value and byte 5 ta 8 is equal ACCESS_PSS
Best way:最好的办法:
const uint8_t ACCESS_PSS [4] = {0x32,0xFD,0x6E,0x2D};
if(memcmp(&ResponseData[i+5], ACCESS_PSS, 4) == 0)
Alternative way (compound literal):替代方式(复合字面量):
if(memcmp(&ResponseData[i+5], (uint8_t[4]){0x32,0xFD,0x6E,0x2D}, 4) == 0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.