How do I clear cout text in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How do I clear cout text in c++?

I've written some code that uses cout a bunch of times and I'm wondering how I could clear the generated text. Thanks in advance :)

11th May 2018, 6:12 PM
valtterim
valtterim - avatar
10 Answers
+ 3
stackoverflow.com/questions/1508490/erase-the-current-printed-console-line or use carriage return (\r) in another cout to clear the previous one. cout<<"hello"; cout<<"\rbye";
11th May 2018, 6:27 PM
Paul
+ 2
https://stackoverflow.com/questions/930138/is-clrscr-a-function-in-c here. clrscr() is a dunction from conio.h library (c library)
11th May 2018, 6:25 PM
Paul
+ 1
oh, but can you try to code onpc then? I do not really truat in SoloLearn compiler that much
11th May 2018, 8:06 PM
Paul
+ 1
It works on PC, but not on the SoloLearn app. Might as well start programming c++ on PC.
12th May 2018, 1:10 PM
valtterim
valtterim - avatar
+ 1
ohh yeah, definitely. Do not bother with c++ on the app, writing on PC gives you that full potential
12th May 2018, 10:37 PM
Paul
0
Sorry but I can't get it to work. clrscr() gives an error saying it hasn't been declared, even though I have #include <conio.h>. /r doesn't do anything. I also tried some other stuff from the links, but they also failed. For the record, I'm coding in the SoloLearn app.
11th May 2018, 7:43 PM
valtterim
valtterim - avatar
0
I don't think you can in SoloLearn
11th May 2018, 8:17 PM
ReimarPB
ReimarPB - avatar
0
your answer is another one in all of this multiple answers, why aren't my per spec? why CLS is better than the others?
13th May 2018, 2:29 PM
Paul
- 1
multiple answers obviously... i would look up proper way.. dont just take what they say. do it per spec. i did look up i got, ("CLS");
13th May 2018, 2:16 PM
Christopher Andrew Holloway
Christopher Andrew Holloway - avatar
- 3
I am not sure
12th May 2018, 1:00 PM
Taryn Williamson
Taryn Williamson - avatar