How do I clear the C++ console? I’m using Replit IDE.
1 Like
system(“cls”) for windows
system(“clear”); For Linux (this replit)
But using system is a security risk if you use it for other things on console.
1 Like
hmm @fpessolano’s answer is great but a faster way is:
#include <iostream>
int main() {
std::cout << "Hello!\033c";
}
there will be no output \033c
clears console
4 Likes
Might be faster indeed. Console and c++ is something I do rarely these days so could be indeed.
1 Like
yeah I tested it, it’s about 10x faster than system, I understand if you don’t do very much of it these days
I use console for debugging and mostly files for logging, feels like a waste to use Cpp for programs using lot of console.
1 Like
Don’t you have to add these headers for this to work:
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif