Advertisement
maujogador

system() alternative

Apr 8th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. void Pause()
  2. {
  3.     printf("Press enter to continue ...");
  4.     getchar();
  5. }
  6.  
  7. void ClearScreen()
  8. {
  9.     HANDLE hStdOut;
  10.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  11.     DWORD count, cellCount;
  12.     COORD homeCoords = { 0, 0 };
  13.  
  14.     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  15.     if (hStdOut == INVALID_HANDLE_VALUE)
  16.         return;
  17.  
  18.     if (!GetConsoleScreenBufferInfo(hStdOut, &csbi))
  19.         return;
  20.     cellCount = csbi.dwSize.X * csbi.dwSize.Y;
  21.  
  22.     if (!FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count))
  23.         return;
  24.  
  25.     if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count))
  26.         return;
  27.  
  28.     SetConsoleCursorPosition(hStdOut, homeCoords);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement