Solved

Clearing the sreen

Posted on 1999-01-21
11
214 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
Cross compile release version of c++ program for linux 2 132
c++ using a LPCOLESTR * and adding a string varaible to the Pointer 2 58
What is sub-make ? 2 58
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

785 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