Clear Screen

I need help to get a new way to clear the screen. I have researched for hours now and can not find a way to get it to work. I know how to use system("cls"). It is way too slow. Can someone please help.

Thanks,
MM
See the MS sample with Console apis.
Thanks, I think i got it now. I might just make my own class for it later. Thanks for the help.

thanks,
MM
much more simply, i try something like this (not sure if its efficient or w/e though)

void clrsc()
{cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";}

that outputs 15 blank lines....hmm, just had an irrelevant thought

void clrsc(int a)
{
for(i,i<=a,i++)
{cout << "\n";}
}

that would output how many blank lines you need, so its reusable in different circumstances
Last edited on
Or even better...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
}
Last edited on
Topic archived. No new replies allowed.