Hello, I use the function Clrscr(), you know, the one from the FAQ.
However, when I do this:
Code:
cout<<"test";
clrscr();
cout<<"only this text should appear";
it doesn't do the clear screen! Instead, it displays this:
testonly this text should appear
But, when I do this:
Code:
cout<<"test"<<endl;
clrscr();
cout<<"only this text should appear";
so with the endl, it works correct! Now it only displays:
only this text should appear
How is this possible? Why do I have to do endl before the function will work?
btw this is the function:
Code:
void clrscr()
{
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);
}