Linux printf output string color

  

Format:
printf("\\033[word background color; font color m string \\033[0m" );

printf("\\033[ ,null,null,3],41; 32m font background is red, the word is green \\033[0m\ ");

41 is the word background color, 32 is the font color, the font background is red, the word is green is a string. The following \\033[0m is the control code.

Color code:

QUOTE:

Word background color range: 40--49 word color: 30--39< Br>

40: Black 30: Black

41: Red 31: Red

42: Green 32: Green

43: Yellow 33: Yellow

44: Blue 34: Blue

45: Purple 35: Purple

46: Dark Green 36: Dark Green

47: White 37: White

ANSI Control Code:

QUOTE:

\\033[0m Turn off all properties

\\033[1m Set high brightness

\\03[ ,null,null,3],4m underline

\\033[5m flashing

\\033[7m反显

\\033[8m blanking

\\033[30m -- \\033[37m setting foreground color

\\033[40m -- \\033[47m setting Background color

\\033[nA Cursor up n lines

\\03[nB Cursor down n lines

\\033[nC Cursor right n lines

\\033[nD Cursor left n lines

\\033[y;xHSet cursor position

\\033[2J Clear screen

\\033[K Clear Content from cursor to end of line

\\033[s Save cursor position

\\033[u Restore cursor position

\\033[?25l Hide cursor

\\33[?25h Display Cursor

This way, dynamic output can be achieved at some point.

Figure:



Copyright © Windows knowledge All Rights Reserved