creating a fresh screen?


How do you delete previous outputs and inputs to the screen leaving only either a new output or the screen prompt?

for example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    cout << "Hello world!" << endl;
    return 0;
}


How would you make these disapear from the screen leaving only the screen prompt?
closed account (DSLq5Di1)
Easiest approach is simply to flood the console with new line characters,

1
2
#include <algorithm>
#include <iterator> 


fill_n(ostream_iterator<char>(cout), 100, '\n');

Some alternatives here:-
http://www.cplusplus.com/articles/4z18T05o/
Last edited on
Topic archived. No new replies allowed.