Clear display

M

Maxd out

Hi

I'm wondering if you can clear a monitor display cout that asks for
something after it's been read in by cin e.g;
cout <<"Enter number" <<endl;
If so how can it be done?
 
T

Thomas Matthews

Maxd said:
Hi

I'm wondering if you can clear a monitor display cout that asks for
something after it's been read in by cin e.g;
cout <<"Enter number" <<endl;
If so how can it be done?

Clearing the screen is a platform specific issue since many platforms
do not support screens. Read the FAQ and welcome.txt below for
more assistance with screen clearing.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
T

torhu

Maxd out said:
Hi

I'm wondering if you can clear a monitor display cout that asks for
something after it's been read in by cin e.g;
cout <<"Enter number" <<endl;
If so how can it be done?

Do you mean outputting something and then clearing the screen?
On DOS/Windows you could probably just do this:

#include<cstdlib>
system("command /c cls");

This is equivalent to typing 'cls' on the command line. Since cls is
a command that is built-in (internal) to command.com, you can't just
say system("cls"). This is because system() needs a real program file
to execute, it can't 'type' commands on the command line like you can
do yourself. :)

If you're on a Linux/Unix system, I think there's a similar solution
there.

Hope I didn't answer the wrong question!
 
D

Dave O'Hearn

Maxd out said:
I'm wondering if you can clear a monitor display cout that asks for
something after it's been read in by cin e.g;
cout <<"Enter number" <<endl;
If so how can it be done?

By clear the display, do you mean wipe the screen clean and start over
at the top line? Or are you talking about something inside of
iostreams, clearing buffers?

For clearing the display like I guessed, that can't be done with
Standard C++ alone. If it's a VT100 terminal, you could send
"\033[H\033[J", which tends to work... but if that doesn't work, or
you want to know more about terminal control, you'll have to look for
a spec, library, or group on ansi terminals, since they aren't part of
standard C++.
 
M

Maxd out

Thank you all for your input, it's given me a lot to think about.
The cls for clear screen sounds logical, but i will also goto the suggested
sites to learn more and try all suggestions.
Thanks again


Dave O'Hearn said:
Maxd out said:
I'm wondering if you can clear a monitor display cout that asks for
something after it's been read in by cin e.g;
cout <<"Enter number" <<endl;
If so how can it be done?

By clear the display, do you mean wipe the screen clean and start over
at the top line? Or are you talking about something inside of
iostreams, clearing buffers?

For clearing the display like I guessed, that can't be done with
Standard C++ alone. If it's a VT100 terminal, you could send
"\033[H\033[J", which tends to work... but if that doesn't work, or
you want to know more about terminal control, you'll have to look for
a spec, library, or group on ansi terminals, since they aren't part of
standard C++.
 
T

Thomas Matthews

torhu said:
Do you mean outputting something and then clearing the screen?
On DOS/Windows you could probably just do this:

#include<cstdlib>
system("command /c cls");

This is equivalent to typing 'cls' on the command line. Since cls is
a command that is built-in (internal) to command.com, you can't just
say system("cls"). This is because system() needs a real program file
to execute, it can't 'type' commands on the command line like you can
do yourself. :)

If you're on a Linux/Unix system, I think there's a similar solution
there.

Hope I didn't answer the wrong question!

So, how do I clear the screen on an embbedded system for a laser
printer?

Is there a standard method to do this?

Perhaps this is why people redirect these issues to the newsgroup
dedicated to the platform.

There are more platforms than just Windows, Linux, Unix, etc.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
A

ArWeGod

torhu said:
Do you mean outputting something and then clearing the screen?
On DOS/Windows you could probably just do this:

#include<cstdlib>
system("command /c cls");

This is equivalent to typing 'cls' on the command line.

Oh, please. How about something a little nicer:

==========================
// CLS.C

#include "dos.h"

void main (void)
{
union _REGS inregs, outregs;

inregs.x.cx = 0x00; // upper left corner
inregs.x.dx = 0x2479; // lower right corner
inregs.h.bh = 0x07; // screen attribute
inregs.x.ax = 0x0600; // BIOS interrupt
_int86 (0x10, &inregs, &outregs);

}

==========================

-
ArWeGod
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top