-
December 2nd, 2008, 05:16 PM
#1
Console window clearing.
I am making a C++ console Blackjack game, and I want it to clear a line, without clearing the whole thing (like CLS)
Is there a reativly simple way to do this?
-
December 2nd, 2008, 05:46 PM
#2
Re: Console window clearing.
Tutorial on Windows OS console API: http://www.adrianxw.dk/SoftwareSite/...Consoles1.html
You'll learn a few tricks - including what you're looking for.
gg
-
December 2nd, 2008, 05:57 PM
#3
Re: Console window clearing.
You can call this function to do it. Make sure you include <windows.h>
Code:
void clrscr()
{
COORD coord_screen = { 0 , 0 };
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD chars_written , con_size;
// get output handle to console
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// work out console size
GetConsoleScreenBufferInfo(hConsole, &csbi);
con_size = csbi.dwSize.X * csbi.dwSize.Y;
// fill with blanks
FillConsoleOutputCharacter(hConsole, TEXT(' '), con_size, coord_screen, &chars_written);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, con_size, coord_screen, &chars_written);
// move cursor to top left corner
SetConsoleCursorPosition(hConsole, coord_screen);
}
-
December 3rd, 2008, 08:18 AM
#4
Re: Console window clearing.
Avoid newbies "tutorials"
Read MSDN, where everything is there. see Console apis reference
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|