clear.cpp

For Cygwin users without a simple clear command on Win32:

1
2
3
4
5
6
7
8
9
10
// clear.cpp
#include <iostream>
using namespace std;

int main()
{
        char a=27u;
        cout << a << "[2J";
        return 0;
}


To compile:

 
g++ clear.cpp -o clear.exe
Last edited on
It'd be nice to see some kind of an explanation along with this code. I don't have any idea what this article is about.
I might as well do this one next... (Now that I can get back to it.)

That code works by emitting the VT100/ANSI escape code to clear the console display and home the cursor. Check here http://www.cplusplus.com/forum/articles/7311/ shortly for more.
Topic archived. No new replies allowed.