在下面的函数中,我正在从UART读取两个字节的十六进制字符。我正在尝试检测数据的开头,即十六进制字符FF
。编译器提供错误error: multi-character character constant
。我该如何宣布FF
?
void getData(void) {
int i;
static uint8_t detectedStartChar = 0;
int buffans[264];
int retchar;
for (i = 0; i < 264; i++) {
retchar = getch(UART_0);
if (retchar == 'DD') {
detectedStartChar = 1;
buffans[i] = retchar;
}
}
}
答案 0 :(得分:1)
正如评论中所提到的,修复是以下任何一种: -
if (retchar == 0xff ){ /* compare the value */
if (retchar == '\xff' ){ /* compare the character representation */