what clear screen command that can be ported in linux?

Hi

What clear screen command that can be ported in linux? I knew of a clear screen command but its not linux portable. I'm reffering to the "system("cls")".

What made me think that its not portable is one of the post here and its says that system() command is not linus protable.

Help! :)
The console command to clear the screen in *Nix is 'clear', so I would assume that the command to do so would probably be
system("clear");
However, I might be wrong on this, as I do not have Linux on my system right now. Hope this helps
Thank you for your reply man. But I was hoping for a command that can work in both linux and windows
1
2
3
4
5
#ifdef LINUX
  system("clear");
#else
  system("cls");
#endif 

Think that should work for you, simple use of the C/C++ preprocessor.
Last edited on
Thanks man!!!!
Just to be clear, while this works, and is the laziest way to do it, it is neither safe/secure nor guaranteed.

If you are just doing homework, ignore my comments.

If you are writing this for any other reason at all, you'll need a better answer. If that is the case let me know.
Topic archived. No new replies allowed.