The standard C console program can also customize the text output color to make the print information clearer, which is particularly useful in debugging. The method is simple:
From: http://www.diybl.com/course/3_program/c/c_js/20090303/157456.html
Start with an example.
Printf ("/033 [31 m ####----->/033 [32 m" "hello/n" "/033 [m ");
The color is divided into the background color and font color, 30 ~ 39 is used to set the font color, 40 ~ 49. Set the background as follows:
Font color of the background color <br/> 40: Black 30: Black <br/> 41: Red 31: Red <br/> 42: Green 32: Green <br/> 43: yellow 33: yellow <br/> 44: Blue 34: Blue <br/> 45: Purple 35: Purple <br/> 46: dark green 36: dark green <br/> 47: white 37: white
In addition, remember to restore the color to NONE after printing, otherwise the subsequent printing will change color.
You can also add some ANSI control codes. Color addition is only one of the following control codes:
/033 [0 m close all properties <br/>/033 [1 m set high brightness <br/>/033 [4 m underline <br/>/033 [5 m flashing <br/>/033 [7 m reverse display <br/>/033 [8 m blanking <br/>/033 [30 m --/033 [37 m set foreground view <br/ >/033 [40 m --/033 [47 m set background color <br/>/033 [nA cursor up n rows <br/>/033 [nB cursor down n rows <br/>/033 [right shift of nC cursor n rows <br/>/033 [left shift of nD cursor n rows <br/>/033 [y; xH set the cursor position <br/>/033 [2J clear screen <br/>/033 [K clear the content from the cursor to the end of the line <br/>/033 [s Save the cursor position <br/>/033 [u restore cursor position <br/>/033 [? 25l hide the cursor <br/>/033 [? 25 h show cursor