c++ - Clean the screen in C -
this question has answer here:
- clearing terminal in linux c++ code 3 answers
- how clear console screen in c? 12 answers
i want clean console screen every 2 seconds, tried use following command:system("clear");
doesn't clear screen. eclipse not recognized file "conio.h" clrscr() function. i'm using ubuntu os. suggestions?
this has been answered before: how clear console screen in c?
basically, it's not cross-platform. if you're using ubuntu, line should work:
printf("\e[1;1h\e[2j");
when test is:
#include <stdio.h> int main(int argc, char *argv[]) { printf("\e[1;1h\e[2j"); printf("3\n"); sleep(1); printf("\e[1;1h\e[2j"); printf("2\n"); sleep(1); printf("\e[1;1h\e[2j"); printf("1\n"); sleep(1); printf("\e[1;1h\e[2j"); printf("0\n"); return 0; }
Comments
Post a Comment