Code:
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <windows.h>
void utilClearScreen(void)
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
return;
}
int main(int argc, char *argv[])
{
char temp;
cout << "Press to clear the screen (then wait 5 seconds)" << endl;
for( ; ; ){
cin.get(temp);
if(temp == 'x')break;
utilClearScreen();
Sleep(5000);
cout << "Press to clear the screen again ('x' then enter to quit)" << endl;
}
return 0;
}
That compiles fine as a console app on DevC++.......it should also compile fine with any other 32Compiler that can create windows apps (VC++, Borland Builder.....).
Hopefully now with all the other options listed above (system("CLS")....etc) this will be the final "Clear the screen" post this board will ever see
:: lives in hope ::