Solved

Clearing the sreen

Posted on 1999-01-21
11
231 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:Ra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1184807
#include <conio.h>

//The function you are looking for is

clrscr();

-Viktor
--Ivanov
0
 
LVL 22

Expert Comment

by:nietod
ID: 1184808
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184809
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 1184810
>> DOS not windows programming
Maybe, but how can you tell for sure?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184811
Here is what the individual said...
>>What I'm looking for is a simple command like CLS in DOS.

-Viktor
--Ivanov
0
 
LVL 22

Expert Comment

by:nietod
ID: 1184812
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.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184813
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
0
 

Author Comment

by:Ra
ID: 1184814
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.
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1184815
Here you go :-)

system("CLS");
0
 

Author Comment

by:Ra
ID: 1184816
Thanks!
0
 
LVL 22

Expert Comment

by:nietod
ID: 1184817
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.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 82
Unable to start eclipse ? 17 174
gdb doesn't stop on breakpoint 2 140
Are the two lines the same? If not what is the difference? 2 30
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question