C/C++ control terminal color output

#define NONE "\033[m"               //正常终端颜色
#define RED "\033[0;32;31m"
#define LIGHT_RED "\033[1;31m"
#define GREEN "\033[0;32;32m"
#define LIGHT_GREEN "\033[1;32m"
#define BLUE "\033[0;32;34m"
#define LIGHT_BLUE "\033[1;34m"
#define CYAN "\033[0;36m"
#define LIGHT_CYAN "\033[1;36m"
#define PURPLE "\033[0;35m"
#define LIGHT_PURPLE "\033[1;35m"
#define YELLOW "\033[1;33m"
#define WHITE "\033[1;37m"          //粗体白色
#define DARY_GRAY "\033[1;30m"      //暗灰色

usage:

printf(LIGHT_RED "this is a debug sentence.\n" NONE);
printf("this is normal output.\n");

effect:
Insert picture description here

Note:
Windows cmd is not supported, but other terminal tools, such as gitbash and vscode built-in terminal are supported

Guess you like

Origin blog.csdn.net/w112348/article/details/112984313