How do I clear the console in BOTH Windows and Linux using C++

前端 未结 12 1511
我寻月下人不归
我寻月下人不归 2020-11-30 01:54

I need a cross platform solution for clearing the console in both Linux and Windows written in C++. Are there any functions in doing this? Also make note that I don\'t want

12条回答
  •  醉梦人生
    2020-11-30 02:24

    Well there is a very close alternative to clearing the screen. You could try using a for loop that repeats new lines a lot. For example:

    for (i = 0; i < 100000; i++)
    {
      printf ("\n\n\n\n\n");
    }
    

    After you do this loop the terminal wan't allow you to scroll back to where you were at the top, an unprofessional approach with common sense pretty much. It does not directly answer what you are asking but it can work.

提交回复
热议问题