FAQ > Clear the screen?

Clearing the screen might seem like a simple thing to do, but answering the question of how to do it isn't. The main problem is that neither standard C nor standard C++ provide any reliable means for clearing the screen. The languages are designed to be platform independant, and platform independence includes the possibility that a "screen" may not even exist. Any interaction with the screen in this manner will impact the portability of your program, so it's important that you keep this in mind when developing. Also keep in mind that clearing the screen in a console mode program may interact in unwanted ways with the output of other programs. Many users do not want their programs to clear the screen for them, especially when their shell supports an easy way to do it themselves.

The best method to clear the screen may be for you to review your compilers documentation and find a suitable non-standard function (such as clrscr from conio.h). The following options will give you the results you desire as quick fixes.

Here are some options that may be open to you.

OPTION 1

Write newline characters until everything has scrolled off of the screen: