0
How can I clear screen when user input something ? In c++
Clear screen
4 ответов
+ 1
There are two ways:
system("cls");
Or:
#include <windows.h>
void ClearScreen()
{
COORD cursorPosition; cursorPosition.X = 0; cursorPosition.Y = 0;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cursorPosition);
}
The second way is much better than the first.
+ 1
When you use system("cls"); in for loop, for example in console snake game, the console will flashing which is irritating. But if you use the second way, there won't be any flashing. On the other hand, if you use first or second method out side the loop, there won't be any difference.
0
What's the difference ?
0
Oh ok thanks for the tip. I don't why sololearn don't have these things