Solved

Clearing the sreen

Posted on 1999-01-21
11
198 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
Comment Utility
#include <conio.h>

//The function you are looking for is

clrscr();

-Viktor
--Ivanov
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
 
LVL 22

Expert Comment

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

Expert Comment

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

-Viktor
--Ivanov
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Here you go :-)

system("CLS");
0
 

Author Comment

by:Ra
Comment Utility
Thanks!
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now