printf("e[1;1He[2J");
This function will work on ANSI terminals, demands POSIX. I assume there is a version that might also work on window's console, since it also supports ANSI escape sequences.
#include <unistd.h>
void clearScreen()
{
const char *CLEAR_SCREEN_ANSI = "e[1;1He[2J";
write(STDOUT_FILENO, CLEAR_SCREEN_ANSI, 12);
}
There are some other
alternatives, some of which don't move the cursor to {1,1}.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…