[C++][Ubuntu]Clear Console Window

Started by
5 comments, last by Anon Mike 16 years, 8 months ago
Hello, Language: C++ Platform: Ubuntu / (possibly windows) I was wondering if there is anyway to clear the console and set the cursor to 0,0 in my Linux program? Is there a cross-platform method for achieving this?
--------------------Enigmatic Coding
Advertisement
Quote:Original post by anothrguitarist
I was wondering if there is anyway to clear the console and set the cursor to 0,0 in my Linux program?


Depends on your needs. ncurses is probably what you're looking for though.

Quote:Is there a cross-platform method for achieving this?


Not that I know of, although I believe there are ports of curses to Windows. Apparently PDCurses is one such port. I don't know how complete it is.
Thank you.

If the port doesn't work on windows, I can just modify the program a bit.
--------------------Enigmatic Coding
If you only wanna clear, then system("clear"); will make it for you :)
Quote:Original post by MSobiecki
If you only wanna clear, then system("clear"); will make it for you :)


Cool, this works on windows too, right?

Is it ok to use system calls?
--------------------Enigmatic Coding
As far as I know main reason's against syscalls are portability and performance, if you are sure, you won't ever need to run app using system("command") under os where command doesn't exist, and that you don't need extreme high performance, or it's not going to have big influence, then use it :)

[edit]
As a matter of fact, system() is usually easier to port than ncurses (yes, you can use pdcurses, but there are some problems with it, and changing commands names isn't that big ammount of work)

under win you have cls not clear, so you will have to make some changes in code, or ifdef'it to make os-sensitive compilation while implementing ;)
Even "cls" isn't guaranteed on Windows. There are wierdos out there that use console shells other than cmd.exe or command.com and those shells might not understand "cls".
-Mike

This topic is closed to new replies.

Advertisement