¿how I can clear the window an start over? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

¿how I can clear the window an start over?

for example I have a calculator and I finish an operation and I want to start from the beggining again, how I can do that with c++ (sorry if I have mistakes I barely know english) ty

8th Jan 2017, 4:29 AM
Hector Vasquez Lopez
Hector Vasquez Lopez - avatar
3 Answers
+ 2
Try to output "\x1b[0;39;49m2J" : this is the clear screen command for console with escape characters... ( '\x1b' is the hex char code for 1b -- 27 decimal -- in python, not sure you escape it by the same way in c++ ) If this work, you can change the end of the string by replacing '2J' by 1J for clear above cursor, and 0J for below ^^
8th Jan 2017, 4:45 AM
visph
visph - avatar
+ 2
??? Escaping char are language independant ^^ Try just: cout <<< "test" <<< endl; cout <<< "\x1b[0;39;49m2J"; ... inside the main function: if you see "test", that's not working, else you will see a blank screen ;) ( I've verified the syntaxe of hex char code in c++ ) Must not work in SoloLearn code playground...
8th Jan 2017, 4:55 AM
visph
visph - avatar
0
ty, but I have doubts if it works un c++ I suppose I need a void and not an int
8th Jan 2017, 4:50 AM
Hector Vasquez Lopez
Hector Vasquez Lopez - avatar