post  clear.cpp

mborja (9)   Link to this post
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
kempofighter (525)   Link to this post
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.
Duoas (2964)   Link to this post
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.

This topic is archived - New replies not allowed.