Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear command prompt with C on windows

Is it possible to clear the output at the command prompt using C on windows?

For example, on linux I could do

printf("\033[2J");

But as far as I know windows doesn't recognise the ANSI escape codes Thanks.

EDIT: I guess I'll also need to get the cursor back to 0,0 fo r the next output after the clear...

like image 206
Toby Avatar asked Dec 12 '22 03:12

Toby


1 Answers

There are many way to do that on windows.

You include conio.h and call _clrscr();

Or you can call system("cls");

like image 90
2501 Avatar answered Jan 03 '23 23:01

2501