Clear Screen using C++

后端 未结 4 1662
小蘑菇
小蘑菇 2020-12-08 05:27

I would like to clear the CMD screen I have seen a few options first is

system(\'clr\');  

but dont want to use system cause then it makes

4条回答
  •  甜味超标
    2020-12-08 06:28

    Try this: it works both on Linux and Windows.

    cout << "\033[2J\033[1;1H";
    

    This is a string of special characters that translate to clear the screen command.

    You can enclose this in a function like e.g. clrscr() depending on your implementation.

提交回复
热议问题