Clearing the screen in C
- July 21st, 2008
- Posted in C . Programming
- By jrod
- Write comment
A simple program that demonstrates one way to clear the screen using ANSI/VT100 terminal control escape sequences
clear.c:
#include <stdio.h>
int
main(){
printf("\x1b[2J\x1b[H");
return 0;
}
(ESC)[2J = Erase screen and set cursor to home
(ESC)[H = return cursor to home (seems redundant but is necessary for some VT’s)
No comments yet.