Wrote a simple program, but given that there is some information that needs to be printed on the console, just like the information displayed by the console when you launch Apache Tomcat on Windows. After a while, the printf was encapsulated, supporting the console print log and supporting the output to the file. But the console is fixed color, not good-looking. So on the internet to find a bit of information, printf also really support the output of different colors, as follows:
Example: printf ("\033[1;33m Hello World.") \033[0m \ n ");
\033 [1; 33m xxxx
| | | |
Start background color Font color string
Some common color codes:
none = "\033[0m"
Black = "\033[0;30m"
Dark_gray = "\033[1;30m"
Blue = "\033[0;34m"
Light_blue = "\033[1;34m"
Green = "\033[0;32m"
Light_green-= "\033[1;32m"
Cyan = "\033[0;36m"
Light_cyan = "\033[1;36m"
Red = "\033[0;31m"
light_red = "\033[1;31m"
Purple = "\033[0;35m"
Light_purple = "\033[1;35m"
Brown = "\033[0;33m"
Yellow = "\033[1;33m"
Light_gray = "\033[0;37m"
White = "\033[1;37m"
[C programming on Linux] make color log records with printf