Clearing output of a terminal program in Linux C

前端 未结 3 761
栀梦
栀梦 2021-02-04 22:35

I want to clear the output of a C program produced with printf statements. I want to clear only one line, for example:

[source]

printf(\"AAAAAAAAAAAAAA\\         


        
3条回答
  •  生来不讨喜
    2021-02-04 22:50

    If you are using X-Term compatibles (Gnome Terminal included), then print the following

    printf("\033[2J");
    

    or

    cout << "\033[2J";
    

    where \033 is the escape character in ASCII and [2J is the specific action (clear).

提交回复
热议问题