Clearscreen

closed account (EvoTURfi)
How do you clear the screen in C++? I tried using clrscr() in <conio.h>, but I learned that this function is only available in the Windows Environment. I'm using Xcode on a Mac, so is there any function that clears the screen available for all platforms? Thanks in advance.
This is a good question.

I use:
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;

Clearing the screen is a platform-specific thing to do, so you need to use platform-specific code. You can choose between which platform's code to use when compiling.

http://www.cplusplus.com/articles/4z18T05o/
closed account (EvoTURfi)
Awesome! Thanks for the replies!

@Duoas
Thanks for the link. I think i'll stick to the string of newlines. It's much easier than the others.
Last edited on
Then do it right, like I give in the article:

1
2
3
4
void ClearScreen()
    {
    cout << string( 100, '\n' );
    }

:-)
Topic archived. No new replies allowed.