When I printf following code, I get hex escape sequence out of range. \x1b is numeric escape for ESC. If my string is literally the 1ESC1, how to represent it?
#include <stdlib.h>
#include <stdio.h>
int main(void){
printf("1\x1b1\n");
return EXIT_SUCCESS;
}
CodePudding user response:
suggest correcting the syntax:
printf("1\x1b\1\n");
CodePudding user response:
"\x1b is numeric escape for ESC" is true, but the hex escape sequence here is \x1b1, not \x1b.
Avoid printf(st) to print a string st. The first argument to printf() is for a format. OK in OP's case, but better to avoid that maybe some escape sequence was used that was the same as %.
Try puts("1" "\x1b" "1");.
