rc-chuah

ClearScreen1

Mar 3rd, 2022 (edited)
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. void ClearScreen() {
  4.     COORD topLeft  = { 0, 0 };
  5.     HANDLE hStdOut;
  6.     DWORD written;
  7.     CONSOLE_SCREEN_BUFFER_INFO screen;
  8.     DWORD dwConSize;
  9.     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  10.     GetConsoleScreenBufferInfo(hStdOut, &screen);
  11.     dwConSize = screen.dwSize.X * screen.dwSize.Y;
  12.     FillConsoleOutputCharacter(
  13.         hStdOut, (TCHAR)' ', dwConSize, topLeft, &written
  14.     );
  15.     FillConsoleOutputAttribute(
  16.         hStdOut, screen.wAttributes, dwConSize, topLeft, &written
  17.     );
  18.     SetConsoleCursorPosition(hStdOut, topLeft);
  19. }
Add Comment
Please, Sign In to add comment