When debugging a program, sometimes you have to output a lot of data, if you let printf/fprintf change the color of the output data, it is much easier to observe data.
The character color of terminal is controlled by escape sequence, and it is the system display function in text mode, which is independent of the specific language.
The escape sequence starts with the ESC and can do the same with \033 (the ASCII code for ESC is in decimal notation is 27, = 33 in octal).
\033[display mode; foreground color; background colour m
Display mode: 0 (default), 1 (highlight), 22 (not bold), 4 (underscore), 24 (non-underlined), 5 (blinking), 25 (non-flashing), 7 (inverted), 27 (non-inverting)
Foreground color: 30 (Black), 31 (red), 32 (green), 33 (yellow), 34 (blue), 35 (magenta), 36 (cyan), 37 (white)
Background color: 40 (Black), 41 (red), 42 (green), 43 (yellow), 44 (blue), 45 (magenta), 46 (cyan), 47 (white)
\033[0m Default
\033[1;32;40m Green
033[1;31;40m Red
printf ("\033[1;31;40m output red character \033[0m")
printf changes color at terminal output