[try Beta version]
Not logged in

 
Clearing the Screen

Nov 1, 2010 at 7:07pm
So, I was wondering about how I would go about clearing the screen in the terminal. I've read that using system("cls") isn't the best way of doing it, so is there a better way than using a system command?
Nov 1, 2010 at 7:10pm
To my knowledge there is not one, but you can just use:
 
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";


EDIT: Although I am not sure if there is enough to move to next screen, but you get the idea...
Last edited on Nov 1, 2010 at 7:11pm
Nov 1, 2010 at 7:16pm
Nov 1, 2010 at 7:46pm
FWIW, console programs probably should not clear the screen anyway.
Nov 1, 2010 at 7:50pm
that \n repetition seems a bit overkill, all of those options seem like way more work than just using system("cls") too.

Is there anything wrong with using a system command other than the command is OS specific, because I was just wanting to clear the screen for a assignment I'm doing for my programming class and I thought that there would be an easy way to do it without spamming \n or writing a whole function. That really helps though Null, I'll have to remember that article if I ever need to clear the screen for programs I do outside of class.
Nov 1, 2010 at 7:54pm
Is there anything wrong with using a system command other than the command is OS specific

http://www.cplusplus.com/forum/articles/11153/
Nov 2, 2010 at 4:35am
Be careful with security.
Nov 2, 2010 at 7:55am
as Disch said, you probably shouldnt want to clear the screen anyway, so why not use \n ;)
and there probably is a non OS specific, but that would be much more work then \n or the os
specific way..
Topic archived. No new replies allowed.