在下面的函数中,我正在从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;
        }
    }
}

最佳答案

如评论中所述,此修复程序是:-

if (retchar == 0xff ){ /* compare the value */

if (retchar == '\xff' ){ /* compare the character representation */

09-15 12:33