1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
// Pausing
std::cin.sync();
std::cin.get();
// Clear Screen - the easy way!
std::cout << std::string('\n', 50);
// Clear Screen - the hard (non portable, assuming windows) way:
#include <windows.h>
void cls(void) {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOut == (void*)ERROR_INVALID_HANDLE)
return;
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)
return;
unsigned long cells = csbi.dwSize.X * csbi.dwSize.Y;
if (!FillConsoleOutputCharacter(hStdOut, ' ', cells, {0, 0}, nullptr))
return;
if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cells, {0, 0}, nullptr))
return;
SetConsoleCursorPosition(hStdOut, {0, 0});
}
| |