?
Solved

Clearing the sreen

Posted on 1999-01-21
11
Medium Priority
?
241 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

719 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