Sign in to follow this  
EnigmaticCoder

[C++][Ubuntu]Clear Console Window

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this