C language output a different color fonts

C language output a different color fonts

\ 8 is 033 decimal, which is a terminal escape unix ESC (16 hex 1A, 10 decimal 27)
the ESC [XM is changed at the terminal of the output color unix command

So, if it is red, then we define as \ 033 [0; 32; 31m

The following test procedures www.cdxsxbx.com

#include <stdio.h>
#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 DARY_GRAY "\033[1;30m"
#define CYAN "\033[0;36m"
#define LIGHT_CYAN "\033[1;36m"
#define PURPLE "\033[0;35m"
#define LIGHT_PURPLE "\033[1;35m"
#define BROWN "\033[0;33m"
#define YELLOW "\033[1;33m"
#define LIGHT_GRAY "\033[0;37m"
#define WHITE "\033[1;37m"

int main ()
{

printf(RED "test1\n"NONE);
printf(LIGHT_RED "test1\n"NONE);
printf(GREEN "test1\n"NONE);
printf(LIGHT_GREEN "test1\n"NONE);
printf(BLUE "test1\n"NONE);
printf(LIGHT_BLUE "test1\n"NONE);
printf(DARY_GRAY "test1\n"NONE);
printf(CYAN "test1\n"NONE);
printf(LIGHT_CYAN "test1\n"NONE);
printf(PURPLE "test1\n"NONE);
printf(LIGHT_PURPLE"test1\n"NONE);
printf(BROWN "test1\n"NONE);
printf(YELLOW "test1\n"NONE);
printf(LIGHT_GRAY "test1\n"NONE);
printf(WHITE "test1\n"NONE);
return 0;
}

Guess you like

Origin www.cnblogs.com/fuoryao/p/11890534.html