Advertisement

ClearScreen in VC++

Started by June 01, 2002 01:37 PM
3 comments, last by No1 22 years, 5 months ago
How do you make a Clearscreen in Visual C++?

  /* Stolen from Eric Tetz''s Win32 console wrapper */bool Clear (){   HANDLE hconsole = GetStdHandle (STD_OUTPUT_HANDLE);   // get the number of character cells in the current buffer   CONSOLE_SCREEN_BUFFER_INFO csbi;   if (!GetConsoleScreenBufferInfo (hconsole, &csbi))       return false;   COORD coordScreen = { 0, 0 };    // here''s where we''ll home the cursor   DWORD cCharsWritten;             // number of chars written by console output routines   DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;   // fill the entire screen with blanks   return (FillConsoleOutputCharacter (hconsole, '' '', dwConSize, coordScreen, &cCharsWritten)              &&           FillConsoleOutputAttribute (hconsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten) &&           SetConsoleCursorPosition   (hconsole, coordScreen));}  


Advertisement
I believe there is a clrsrn() function or something like that in conio.h - try searching for it in help.
quote: Original post by Arkainium
I believe there is a clrsrn() function or something like that in conio.h - try searching for it in help.

No, there''s not. Anyway, what you''re thinking of is clrscr().

quote: Original post by Arkainium
I believe there is a clrsrn() function or something like that in conio.h - try searching for it in help.


conio.h is non-standard. The Clear() function shown above will work fine. You can also use system("cls"), though a lot of people frown on using system().



MSVC++ 6
DirectX 7

[edited by - jdinger2 on June 1, 2002 9:08:32 PM]
MSVC++ 6DirectX 7

This topic is closed to new replies.

Advertisement