How do I clear the screen in a console app (c++)
Ok, I'm not writing a game but I figured this is the best place for a piece of advice. How do I simply clear the screen? I know there is a command. I just don't know it. :)
Thank You.
i hate it how ther's no universal solution (cross platform) to this common problem.. or is there?
Printing out lots and lots of spaces and/or newlines.
Unfortunatley I don't know of a command that works on both unix and windows.
Course you could always get the user to create an alias that alias one to the other, but yes this is a stupid idea.
Unfortunatley I don't know of a command that works on both unix and windows.
Course you could always get the user to create an alias that alias one to the other, but yes this is a stupid idea.
Quote:Original post by BoderDoesn't seem to work with Mingw/GCC.
Or system("clear")
#include <iostream>main(){ std::cout << "Hello World...\n\nPress Enter."; std::cin.get(); std::system("cls"); std::cout << "Once Again, Hello World!\n\nPress Enter."; std::cin.get();}
Quote:Original post by Rob LoachQuote:Original post by BoderDoesn't seem to work with Mingw/GCC.
Or system("clear")
*** Source Snippet Removed ***
It is not up to the compiler, it is up to the system.
"clear" isn't a command in my windows too.
The correct one is as Meta Adam said, its system("cls") as cls is the clear command for the windows command prompt (carried over from the old dos operating systems) clear is for linux systems.
Quote:i hate it how ther's no universal solution (cross platform) to this common problem.. or is there?
Oh, but there is (assuming a terminal that supports VT100).
The escape sequence is ^[[2J. In C++, that's cout << "\33[2J". See VT100 escape codes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement