Reputation: 35
When I write some code with ANSI escape sequence like.... \e[4m ~ \e[0m
,
I got the error that
C4129 'e': unrecognized character escape sequence
and the program show me that escape sequence did not set and just indicates \e[4Hello\e[0
.
How can I fix it?
Upvotes: 3
Views: 1729
Reputation: 29012
The \e
is supposed to insert an ESC character (ASCII code 27), but it doesn't exist in standard C, only in some nonstandard extensions.
You can use \33
instead1. (33 is the octal representation of decimal 27.)
1: This will work fine (and is the shortest way) for regular ANSI escape sequences since the following character will always be [
. But in case you ever need to use the ESC character in other circumstances, please note that you'll need \033
in case it is followed by a digit between 0 and 7, because otherwise that next digit would errornously be considered part of the octal number. As dxiv mentioned in the comments, it may be the case with some VT100 escape sequences.
Upvotes: 5