i have these code for clear the screen:
//clear the Console
void Clear(int BackColor=0)
{
// home for the cursor
COORD coordScreen = {0, 0};
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), (WCHAR)' ', dwConSize, coordScreen, &cCharsWritten))
return;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15|BackColor<<4 );
// 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);
}
i see at least 1 problem: after clear, the text color is, always, white and not the last color. can anyone advice me?