+ 2

clear screen on sololearn

Why can't I clear screen on solo learn as below : #include <iostream> #include <cstdlib> using namespace std; int main ( ) { cout << " Hi \n"; system("cls"); cout << "Hello\n"; return 0; } I need any means to print only Hello instead of Hi and Hello in two different lines on this application itself.. any thought would be of great help...

31st Aug 2018, 6:40 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Réponses
+ 4
Other than omitting the first cout and system call... The basic problem is that the output panel is not a terminal. On the off chance a version of seek() would work I tried a few things. seekp() on stdout / cout looked promising, and while the stream does support seeking, nothing useful seems to happen. Seeking to -1 prevents output, 0 does not overwrite, and \r (to return the 'carriage', or cursor) to position 0 fails. Here's one I tried*; you have to add main() and call with a number. https://stackoverflow.com/a/38619207 If it worked, you'd see 1 line on 2 calls; I see 2. * From main topic: https://stackoverflow.com/questions/3277058/how-to-rollback-lines-from-cout
31st Aug 2018, 7:27 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
I could not get anything to update existing output or new line output...below is what best I could do : https://code.sololearn.com/cixc48Z9L1jh/?ref=app
1st Sep 2018, 6:00 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
give me thé code c++
1st Sep 2018, 2:51 PM
salimbibo