十六进制转义序列超出 C 的数字转义范围
hex escape sequence out of range for numeric escape of C
当我 printf
跟随代码时,我得到 hex escape sequence out of range
。对于 ESC
,\x1b
是 numeric escape
。如果我的字符串字面上是 1ESC1
,如何表示它?
#include <stdlib.h>
#include <stdio.h>
int main(void){
printf("1\x1b1\n");
return EXIT_SUCCESS;
}
建议更正语法:
printf("1\x1b\n");
“\x1b is numeric escape for ESC”是正确的,但是这里的hex转义序列是\x1b1
,而不是\x1b
.
避免printf(st)
打印字符串st
。 printf()
的第一个参数用于格式。在 OP 的情况下可以,但最好避免使用与 %
.
相同的转义序列
尝试puts("1" "\x1b" "1");
。
当我 printf
跟随代码时,我得到 hex escape sequence out of range
。对于 ESC
,\x1b
是 numeric escape
。如果我的字符串字面上是 1ESC1
,如何表示它?
#include <stdlib.h>
#include <stdio.h>
int main(void){
printf("1\x1b1\n");
return EXIT_SUCCESS;
}
建议更正语法:
printf("1\x1b\n");
“\x1b is numeric escape for ESC”是正确的,但是这里的hex转义序列是\x1b1
,而不是\x1b
.
避免printf(st)
打印字符串st
。 printf()
的第一个参数用于格式。在 OP 的情况下可以,但最好避免使用与 %
.
尝试puts("1" "\x1b" "1");
。