Clear Screen?

T

Tim Mierzejewski

How do I clear the text from my screen, other than a bunch of \n's or
endl's?

Tim M.
 
U

Unforgiven

Tim said:
How do I clear the text from my screen, other than a bunch of \n's or
endl's?

C++ can not clear the screen, as indicated in the FAQ Victor pointed you to.
However, you can ask the OS to do it for you. The most common ways to do
this are 'system("cls");' in Windows and system("clear");' in Linux. The
system function is defined in <process.h>

--
Unforgiven

"Not only do I not know the answer
I don't even know what the question is"
My world - Metallica
 
A

Ashish

Unforgiven said:
C++ can not clear the screen, as indicated in the FAQ Victor pointed you
to.

Huh? C++ can do a lot of things using the OS specific libraries. Dont say
C++ cannot clear the screen. Instead, you should say standard C++ cannot
clear the screen.
 
V

Victor Bazarov

Ashish said:
to.

Huh? C++ can do a lot of things using the OS specific libraries. Dont say
C++ cannot clear the screen. Instead, you should say standard C++ cannot
clear the screen.

That's the only C++ we speak of here.
 
V

Victor Bazarov

Ashish said:
Thats what I said too... but dont misguide the OP by saying that C++ cannot

Misguide?

do this, or can do that. Guide him to an appropriate newsgroup. I am sure
you understand that.

But in all honesty, C++ cannot clear the screen. It's some OS-
specific library call that does that. Or sequence of characters
output to console or ... But it is not a language thing. And,
by the way, while there exist extensions to the language created
by some eager compiler vendors, there is only one C++ -- Standard.

That's what we mean when we say "C++ cannot do that". Another
example: can C++ read files? Yes. Can C++ read JPEG files? Yes.
Can C++ read and display JPEG files? NO. Displaying them is not
a language feature. C++ cannot do that. Not standard, not any
other C++. The same with clearing the screen.

Guiding others to a particular newsgroup is a voluntary thing. If
you stop me in the street and ask whether I could give you a lift
to a town a thousand kilometres away, I'll probably say "No, sorry,
I cannot do that", but I am not obligated to explain to you all
possible options you have or direct you to a bus station. It is
up to you to figure that out. (Of course it might be mighty kind
of me to point you to a bus stop, and I _probably_ would do that
if I knew where you were going -- The OP just asked whether there
was a way to clear the screen except outputting newline characters,
and there isn't). See the point?

Anyway...

Victor
 
A

Ashish

Victor Bazarov said:
But in all honesty, C++ cannot clear the screen. It's some OS-
specific library call that does that. Or sequence of characters
output to console or ... But it is not a language thing. And,
by the way, while there exist extensions to the language created
by some eager compiler vendors, there is only one C++ -- Standard.

That's what we mean when we say "C++ cannot do that". Another
example: can C++ read files? Yes. Can C++ read JPEG files? Yes.
Can C++ read and display JPEG files? NO. Displaying them is not
a language feature. C++ cannot do that. Not standard, not any
other C++. The same with clearing the screen.

Guiding others to a particular newsgroup is a voluntary thing. If
you stop me in the street and ask whether I could give you a lift
to a town a thousand kilometres away, I'll probably say "No, sorry,
I cannot do that", but I am not obligated to explain to you all
possible options you have or direct you to a bus station. It is
up to you to figure that out. (Of course it might be mighty kind
of me to point you to a bus stop, and I _probably_ would do that
if I knew where you were going -- The OP just asked whether there
was a way to clear the screen except outputting newline characters,
and there isn't). See the point?

Anyway...

Victor

I agree with you. But if you tell me that you cannot give me a lift to a
thown a thousand kilometers away doesnt mean that you should tell me that
there is no way I can go to that town. Thats what the other person did. He
said that C++ cannot... I am not saying that he or you HAVE to guide the OP
to an appropriate newsgroup, its voluntary ofcourse, but dont MISguide him
saying that it cannot be done. Get it?
 
A

Ashish

Victor Bazarov said:
But in all honesty, C++ cannot clear the screen. It's some OS-
specific library call that does that. Or sequence of characters

And those OS-specific libraries cannot be used using C++. I get it now.
 
V

Victor Bazarov

Ashish said:
I agree with you. But if you tell me that you cannot give me a lift to a
thown a thousand kilometers away doesnt mean that you should tell me that
there is no way I can go to that town. Thats what the other person did.

No. Using the same analogy, the other person told you that you
can't get to another town in Victor's car. He didn't say that
clearing of the screen cannot be done. He said that clearing of
the screen cannot be done with C++. Get it?
He
said that C++ cannot...

And you think that C++ can? Show me.
I am not saying that he or you HAVE to guide the OP
to an appropriate newsgroup, its voluntary ofcourse, but dont MISguide him
saying that it cannot be done. Get it?

Do you understand the difference between "it cannot be done" and
"it cannot be done using C++ means"? Saying the latter does NOT
imply the former, and in no way is misguiding. Get it?
 
A

Ashish

Victor Bazarov said:
No. Using the same analogy, the other person told you that you
can't get to another town in Victor's car. He didn't say that
clearing of the screen cannot be done. He said that clearing of
the screen cannot be done with C++. Get it?


And you think that C++ can? Show me.


Do you understand the difference between "it cannot be done" and
"it cannot be done using C++ means"? Saying the latter does NOT
imply the former, and in no way is misguiding. Get it?

Oh, why am I arguing with you anyways? I reinstalled my OS and lost all the
news and email filters. Time to ignore you and Dan Poop again. Goodbye.
 
D

Default User

Ashish said:
Oh, why am I arguing with you anyways? I reinstalled my OS and lost all the
news and email filters. Time to ignore you and Dan Poop again. Goodbye.


Is there some reason you had three screens worth of quotes for this tiny
reply?



Brian Rodenborn
 
A

Ashish

Default User said:
Is there some reason you had three screens worth of quotes for this tiny
reply?

Yes. A couple of reasons actually. First, it has become an off-topic thread
and anyone who cares to read off-topic posts should probably take the
efforts to scroll down to the bottom. Second, I am too lazy.
 
J

Jack Klein

to.

Huh? C++ can do a lot of things using the OS specific libraries. Dont say
C++ cannot clear the screen. Instead, you should say standard C++ cannot
clear the screen.

I guarantee you that I can show you several systems where C++,
standard or not, cannot clear the screen. For the simple reason that
there IS NO SCREEN. One of the reasons C++ does not support a screen
is that it does not require one.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
A

Ashish

Jack Klein said:
I guarantee you that I can show you several systems where C++,
standard or not, cannot clear the screen. For the simple reason that
there IS NO SCREEN. One of the reasons C++ does not support a screen
is that it does not require one.

I am sorry, I had put my statement wrongly. But, since the OP asked about
clearing the screen, I assumed he had a screen (a computer monitor).
 
K

klaas

you do not want to use process.h since it is not platform independant,
use stdlib.h instead

regards

pol jak
 
S

Stephen Howe

Is there some reason you had three screens worth of quotes for this tiny

Laziness.

I hate the griping about top posting in the newsgroup (which is a heinous
crime IMO and come the revolution, top-posters will be second against the
wall to be shot with me in the role of executioner).

But some people who gripe against top-posters commit the equally henious
crime of not pruning old conversation. Why should I have to download reams
of old conversation and then scroll through it just to see a reply? IMO they
are more guilty than top-posters (and again, come the revolution,
non-pruners will be first against the wall to be shot with me in the role of
executioner).

Stephen Howe
 
S

Stephen Howe

I guarantee you that I can show you several systems where C++,
standard or not, cannot clear the screen. For the simple reason that
there IS NO SCREEN. One of the reasons C++ does not support a screen
is that it does not require one.

I agree with you. But lets go further...

Equally I can show you systems where there is NO SUCH THING AS A FILE. So
why does both C and C++ provide stdio/streams? That is an OS thing and IMO,
should be removed.

Also the assumption that dynamic memory is available via new/malloc() should
be removed. That also is an OS thing and IMO should be removed.

Stephen Howe
 
A

Ashish

Stephen Howe said:
Laziness.

I hate the griping about top posting in the newsgroup (which is a heinous
crime IMO and come the revolution, top-posters will be second against the
wall to be shot with me in the role of executioner).

But some people who gripe against top-posters commit the equally henious
crime of not pruning old conversation. Why should I have to download reams
of old conversation and then scroll through it just to see a reply? IMO they
are more guilty than top-posters (and again, come the revolution,
non-pruners will be first against the wall to be shot with me in the role of
executioner).

No problem.... here I am, shoot me, spam my email address, hack my website,
DOS attack my webserver and do whatever you feel like.
I visit this newsgroup for advise and sometimes even help others. I dont
like top posters and non-pruners too. But when people weep over not pruning
posts in some stupid off topic post, it pisses me off. Please dont read this
message, it has nothing to do with C++.

-A
 
D

Default User

Ashish said:
Yes. A couple of reasons actually. First, it has become an off-topic thread
and anyone who cares to read off-topic posts should probably take the
efforts to scroll down to the bottom. Second, I am too lazy.

Neither is a good excuse.

1. We can't really rail at the top-posters when people validate their
point by failing to edit the quotes down to a reasonable subset. If a
post is worth responding to, it's worth taking the time to do it
correctly. If not, then the better solution is to not reply at all. The
fact that it was OT does not matter.

2. I find it difficult to believe that it was that much work. I used to
use trn with vi as the editor, yet always managed to trim quotes. You
use a windows based newsreader, where you merely needed to drag down on
some text and hit delete.



Brian Rodenborn
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top