Universal OS screen clear?

Is there a universal OS screen clear function? To my understanding system("cls") is for windows, system("ls") can be used for Linux (please correct me if wrong) but I am using a Mac for programming and my professor uses windows, I would like to clear the screen at certain points to neaten things up. Any advice is appreciated.
hi gmenfan83

i'm afraid i do not have the answer to your question, but i wish to clarify about system("ls").

the command "ls" is used to list folders in the directory for linux. the right command to clear the screen is "clear".
I see, thanks, I know the ls-command from terminal on a Unix machine I just saw someone say it was able to be used Linux trying to clear the screen. I am strictly speaking in terms of c++ also, no terminal commands.
Last edited on
Nice attitude, gmenfan83, no shell/system commands. They aren't safe, and bla, bla, bla...
http://www.cplusplus.com/articles/4z18T05o/
Thanks EssGeEich!
Anyways, there is no 'single' clear screen functions, you can make your own with IFDEF's depending on the OS.
Ah, I won't even worry about it I suppose. Its no biggie, I just like things to astetically look pleasing. Thanks for the tips though!
Last edited on
Clearing the screen is a system-specific thing to do.

You really don't need to do it for homework stuff. If undaunted, though...

If you don't think that using system() will get you into trouble with your professor, use:

if (system( "cls" )) system( "clear" );

If your professor is using Windows, this will probably cause his virus scanner to pop up complaining that your program is doing something uncouth.

The actual, proper way to do this kind of thing is explained in the Clear the screen Article:
http://cplusplus.com/articles/4z18T05o/

This requires a little bit of extra work when compiling on POSIX systems though... (you will have to link with libcurses).

Good luck!
Thank you Duoas!
Topic archived. No new replies allowed.