How to clear the screen in DOS
-
:sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!
-
:sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!
-
:sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!
Here is you solution If you working in Text mode see cls() function it is defined in if you working in Graphis mode see function cleardevice() ,it is defiend in graphics.h ----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk
-
:sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!
>>erase all previous lines). For dos baserd compiler... the function is:
clrscr();
The header file for it is#include
conio=Console I/O I hope that makes you happy. :) ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
-
:sigh: I am just starting with C++, and have a problem. I wrote a text game but the thing is some times I want the new question etc to start at the top of a clean black screen (that is erase all previous lines). I could just put a pile of endl; but a couple of days ago somewhere on the site I saw a clrScrn; statment or something like that and remembered BASIC. Could someone tell me the the #include and the correct way to use it. Thanks in advance!
im assuming you have Visual C++, unfortunatly VC++ doesnt come with the old functions like gotoxy() or clrscrn() that Dev-C++ offers here is a ClearScreen() function i wrote along time ago (with SetXY() function) void SetXY(int X, int Y){ COORD dwCoord; dwCoord.X = X; dwCoord.Y = Y; SetConsoleCursorPosition(STDHANDLE,dwCoord); } void ClearScreen(){ COORD dwCoord; DWORD nLength; DWORD lpResult; CONSOLE_SCREEN_BUFFER_INFO Info; GetConsoleScreenBufferInfo(STDHANDLE, &Info); dwCoord.X = 0; dwCoord.Y = 0; nLength = Info.dwSize.X * Info.dwSize.Y; FillConsoleOutputCharacter(STDHANDLE, ' ', nLength, dwCoord, &lpResult); SetXY(0,0); } ohh i almost forgot #define STDHANDLE GetStdHandle(STD_OUTPUT_HANDLE)