Clearing output of a terminal program in Linux C
There're several ways to delete the DDDDDDDDDDDDDD
- Print backspace several times
printf("\b");
- Print carriage-return and then print something to override the original line
printf("\r");
- If you are in a newline. You may use terminal commands to move your cursor
such as printf("\033[8;5Hhello"); // Move to (8, 5) and output hello
Other commands:
printf("\033[XA"); // Move up X lines;printf("\033[XB"); // Move down X lines;printf("\033[XC"); // Move right X column;printf("\033[XD"); // Move left X column;printf("\033[2J"); // Clear screen...
- Don't forget ncurses
It is the best ways to control the exact layout and format in a terminal
I tried answering for what is best expected here.
printf("AAAAAAAAAAAAAA");printf("BBBBBBBBBBBBBB");printf("CCCCCCCCCCCCCC");//printf("DDDDDDDDDDDDDD");
comment the last line or delete if you dont want to display in terminal. printf("xxxx") is the statement used for printing output in terminal.