Jump to content
  • Advertisement
Sign in to follow this  
EnigmaticCoder

[C++][Ubuntu]Clear Console Window

This topic is 3990 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!