ANSI Escape Code
There is a standard made based on an ANSI to control the outputs made in a text terminal.
The manipulation of these outputs is done by commands called ANSI Escape Codes , which are enabled by the 27 or 1B value character in hexadecimal ( Esc button) followed by [ (opens bracket), after that, a value and a letter are passed to represent your action.
Examples
To position the cursor in a certain position on the screen, use the letters H or f , passing along the line and the column to the cursor. p>
printf("\x1B[%d;%dH",6, 5);
printf("\x1B[%d;%df",6, 5);
To clear the screen, use 2 followed by the J character.
printf("\x1B[2J");
To change the color of the text to be written, use the color value followed by m .
printf("\x1B[31mRed"); // Escreve em vermelho
printf("\x1B[01;32mBoldGreen"); // Escreve em verde e negrito
printf("\x1B[00mTexto Normal"); // Retira estilo