Skip to content
How to clear screen in C++
Profile icon

I need a function that can clear my console screen on this website. I do know the method of printing 50 lines, but that is not what I am looking for.

You are viewing a single comment. View All
Answered by Geocube101 [earned 5 cycles]
View Answer
Profile icon

void moveCursor(int x, int y)
std::cout << "\033[" << y << ";" << x << "H";
calling this function with the parameters 0,0 would move your cursor back to the top left of the console window, allowing you to overwrite all your stuff with new stuff. Useful if you want to avoid that flicker you get from the other thing.