Link to home
Start Free TrialLog in
Avatar of Ra
Ra

asked on

Clearing the sreen

I am programming C++ Source file and I want to know how to clear all the text from the screen before I cout anything else.  I searched through help and didn't find anything.  There has to be some command that will do this.  (Please include any header files that I need for that command.)  What I'm looking for is a simple command like CLS in DOS.
Thanks in advance.
Avatar of viktornet
viktornet
Flag of United States of America image

#include <conio.h>

//The function you are looking for is

clrscr();

-Viktor
--Ivanov
Avatar of nietod
nietod

conio.h and clrscr() are not part of the standard C++ library.  Some implimentations may provide them some might not.  MS VC++, for example, does not.  In fact, standard C++ does not provide ANY way to clear the screen--because it doesn't necessarily run on a screen.   Thus you will have to use some sort of implimentation--specific solution.  (like conio.)  Thus if conio isn't available, we need to know what OS you are developing for and what compiler you are using.
nietod, he/she is talking about DOS not windows programming, thus the person can use conio without problems... If it is not on a Unix system, then conio.h can be used, and most of the DOS compilers provide it nowadays...

-Viktor
--Ivanov
>> DOS not windows programming
Maybe, but how can you tell for sure?
Here is what the individual said...
>>What I'm looking for is a simple command like CLS in DOS.

-Viktor
--Ivanov
I intepret that to mean that he/she is looking for a command that works like the CLS does in DOS.  i.e simple command like [CLS in DOS].  Not as [simple command like CLS] in DOS.  Well, we'll see.
clrscr() does exactly what CLS does in DOS....you could also do this...

system("CLS");

but it doesn't always work properly...

you can write your own clrscr() routine for DOS using asseembler..the address to text mode is 0xB000

-Viktor
--Ivanov
Avatar of Ra

ASKER

Let me clarify. I have Microsoft Visual C++ 5.0, running on Windows 95.  I am in a C++ class and right now we are not doing any Windows development.  All of the programs that we are doing are programmed using C++ source files that send output to a DOS window.  The system("CLS"); does work for what I am doing but the clrscr() gives the error undeclared variable.  viktornet, since you gave the answer that helped me, post the system("CLS"); as the answer and I'll give you the points.
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ra

ASKER

Thanks!
As I said, not a DOS program.  I think the proper way to handle the screen in this case would be to use the WIN32 console functions.