If you are using visual studio 2008 or 2005 and have the platform SDK installed with it and configured correctly. (You can use other IDE's with the platform SDK as long as you have it set up correctly)
So if you have that installed and #include <windows.h>
You can use:
system("cls");
or something like this - by bliting an array to the screen which is a little hard to learn but a very a good method as printf() and std::cout take a lot of time:
void ClearScreen()
{
COORD coordScreen = {0, 0}; // home for the cursor
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
// Get the number of character cells in the current buffer.
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return;
}
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Fill the entire screen with blanks.
if(!FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten))
{
return;
}
// Get the current text attribute.
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return;
}
// Set the buffer's attributes accordingly.
if(!FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
{
return;
}
// Put the cursor at its home coordinates.
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordScreen);
}