Chat on IRC |
Clear Screen in C++
Posted by eternaldisciple [send private reply] at October 04, 2001, 08:30:56 AM
What is the easiest way to clear the screen under DOS using C++. Right now I'm using system calls in the form of
system("CLS"); It works but it's slow. Thanx for help.
Posted by taubz [send private reply] at October 04, 2001, 12:33:31 PM
clrscr()? Or am I thinking of TI-85 programming?
- taubz
Posted by RedX [send private reply] at October 04, 2001, 02:14:48 PM
An other way is to reset the video mode.
AH = 00h AL = 03h then call interrupt 10h void SetText() { _AX = 0x0003; // same as setting AH = 00h and AL = 03h geninterrupt(0x10); } Not the fastest way to do it. But the easiest one (at least to find around here, big pile of handbooks, engineering journals, loose paper, and more, I don't intent to mess too much with it, at least not until I can disable gravity). A better way to do it, is to fill the VGA memory with a plain color (black for example) This takes one memset. (or write it in ASM) (See Denthor's VGA trainer) RedX
Posted by PredeX [send private reply] at October 05, 2001, 07:47:46 AM
Well there are a few commands in C i know of, dont know if they work under C++ though. And if you dont work under win95 or 98, they dont work, because they only work under DOS. So you need the right drivers which support these command. So you search for ANSI.SYS and set that path in your CONFIG.SYS like this:
Device=C:\...<path>...\ANSI.SYS. Then restart your computer, so that those drivers are loaded. And here's the code example: #include <stdio.h> //or whatever.... #define CLS printf("\033[2J"); //this will clear the screen when called //upon int main() { CLS; //clears the screen <alot of code>; CLS; //clears the screen return 0; //or whatever } As i said this only works if you r running a OS which supports DOS, and im not sure if it works in C++, cuz the example is in C ;). *PredeX*
Posted by sphinX [send private reply] at October 06, 2001, 01:36:46 AM
um...why is this any better than clrscr()? you're way requires whoever runs the program to have ansi.sys as a driver...
Posted by PredeX [send private reply] at October 06, 2001, 12:16:48 PM
@sphinX:
I didnt say that this is any better than clrscr() or did I (re-reading my text...conclusion: Nope!) This is just an alternative, not a very good one though, i have to admit, because it only works, as you said sphinX, when the ansi.sys drivers are loaded. (I tested it under win2k and it didnt work...) *PredeX*
Register as a new user | ||||||||