// test of the official Windows Console clear the screen function // tested with Pelles C vegaseat 26mar2005 #include <stdio.h> void clrscr(void); #include <windows.h> void clrscr(void) { COORD coordScreen = { 0, 0 }; // upper left corner DWORD cCharsWritten; DWORD dwConSize; HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hCon, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; // fill with spaces FillConsoleOutputCharacter(hCon, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hCon, &csbi); FillConsoleOutputAttribute(hCon, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); // cursor to upper left corner SetConsoleCursorPosition(hCon, coordScreen); } int main(void) { int k; for(k = 0; k < 25; k++) { printf("Test........\n"); } printf("Press Enter..."); getchar(); clrscr(); getchar(); // wait return 0; }