How to clear screen in console application (C++)

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
I can't find the command to clear the screen when I run the .exe that I compiled.

What command do I put in my source code?
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
printf( "\33[2J"); // Example in C/C++

That works for me under Linux/GCC. I don't know about Windows, but it should.

And this makes it do everything including return the cursor to the beginning:

printf( "\033[0m\033[2J\033[H");
 

Apathetic

Platinum Member
Dec 23, 2002
2,587
6
81
Originally posted by: xtknight
printf( "\33[2J"); // Example in C/C++

That works for me under Linux/GCC. I don't know about Windows, but it should.

And this makes it do everything including return the cursor to the beginning:

printf( "\033[0m\033[2J\033[H");

Wow.... It's been YEARS since I've seen those ANSI sequences!

Dave