In ANSI compatible terminals (such as xterm, rxvt, and konsole), texts can be displayed in color, not just in black and white. HoweverProgramCan I output color characters? Of course, the answer is yes. The following statement outputs the highlighted black background green text.
Printf ("\ 033 [1; 40; 32 M % s \ 033 [0 m", "hello, nsfocus \ n ");
\ 033 declares the start of the escape sequence, and then [begins to define the color. The following 1 defines the highlighted characters. Then there is the background color, where 40 represents the black background. Next is the foreground color, which is 32, indicating green. We use \ 033 [0 m to close the escape sequence, and \ 033 [0 m is the default terminal color.
Through the above introduction, we will know how to output color characters. So I will not talk about it any more. The following are some definitions of color character colors:
Foreground background color
------------------------------------- 30 40 black 31 41 yellow 32 42 yellow 33 43 yellow 34 44 yellow 35 45 purple yellow 36 46 green yellow 37 47 whiteCodeMeaning ------------------------- 0 terminal default settings 1 Highlight 4 Use underline 5 Flash 7 reverse white display 8 invisible
The STD: cout of PS: C ++ can also be used.