ANSI escape codes not displaying correctly

后端 未结 1 1412
忘了有多久
忘了有多久 2021-01-27 02:59

I have the following defines:

#define ANSI_COLOR_RED     \"\\e[31m\"
#define ANSI_COLOR_GREEN   \"\\e[32m\"
#define ANSI_COLOR_YELLOW  \"\\e[33m\"
#define ANSI_C         


        
相关标签:
1条回答
  • 2021-01-27 04:02

    Notice that \e is not a standard escape code and may thus fail (behaviour is undefined!):

    % gcc ansi.c -pedantic
    ansi.c: In function ‘main’:
    ansi.c:4:12: warning: non-ISO-standard escape sequence, '\e'
         printf("\e[1;32mfoobar");
    

    Use \033 or \x1B instead.

    0 讨论(0)
提交回复
热议问题