By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

ANSI clear screen [MS & Borland]

P: n/a
Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie
Nov 13 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Search for "Microsoft Knowledge Base Article - 99261"

That should work on both compilers given that you're making a win32 console
application.

--

Elias

"ritchie" <ri*********@yahoo.com> wrote in message
news:3b**************************@posting.google.c om...
Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie

Nov 13 '05 #2

P: n/a
ritchie wrote:

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers,
especially Borland & MS Visual Studio 6.


Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.

After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 13 '05 #3

P: n/a
CBFalconer wrote:
Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.
And that (as you know) isn't a portable technique either.

After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #4

P: n/a
Greetings.

In article <3b**************************@posting.google.com >, ritchie
wrote:
Is there anything that will clear the screen in both and maybe also
work on gcc?


Maybe putchar('\f')... if that doesn't work, use the compiler-provided
implementations and wrap them around #defines. (Presumably each
compiler will #define some macro identifying it. I know GCC does. If
Borland and Microsoft don't, you're probably out of luck.)

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #5

P: n/a
Richard Heathfield <do******@address.co.uk.invalid> wrote:
CBFalconer wrote:


[How to clear screen]
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)


No need to put it back. I use a damp cloth and a tiny little bit of
detergent to clear the screen, and the data doesn't get rubbed off -
it stays nice and clear where it was. :)
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc : http://www.angelfire.com/ms3/bchambl...me_to_clc.html
clc faq-list : http://www.eskimo.com/~scs/C-faq/top.html
acllc-c++ faq : http://www.contrib.andrew.cmu.edu/~a...acllc-c++.html
Nov 13 '05 #6

P: n/a
On Sat, 06 Dec 2003 21:19:40 +0100, in comp.lang.c , Irrwahn
Grausewitz <ir*******@freenet.de> wrote:
Richard Heathfield <do******@address.co.uk.invalid> wrote:
CBFalconer wrote:


[How to clear screen]
> After all that, don't do it. There is nothing more annoying than
> gratuitious screen clearings from imbecelic programs removing data
> I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the current
terminal window), as long as he puts the old data back afterwards. :-)


No need to put it back. I use a damp cloth and a tiny little bit of
detergent to clear the screen, and the data doesn't get rubbed off -
it stays nice and clear where it was. :)


I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #7

P: n/a
Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.

Nov 13 '05 #8

P: n/a
On Sat, 06 Dec 2003 16:56:38 -0600, in comp.lang.c , Morris Dovey
<mr*****@iedu.com> wrote:
Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


See, these problems wouldn't arise if people didn't give offtopic
answers here. Any fule kno that your kind of router is pronounced to
rhyme with shouter, and the sort you /should/ have wiped with solvent
is pronounced to assonate with tooter. If only you yanks could learn
to spel too, we'd be laffin.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #9

P: n/a
Richard Heathfield wrote:
CBFalconer wrote:
Since you carefully read the FAQ, you are now aware that this
cannot be done in standard C. About the closest you can come is:
^^^^^^^

puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");

and you may need to adjust the \n count.
And that (as you know) isn't a portable technique either.


Note underlined word above :-)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic programs removing data
I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the
current terminal window), as long as he puts the old data back
afterwards. :-)


Disagree. Consider a calculator program. While using it I want
the data that was previously left on my screen.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 13 '05 #10

P: n/a
>I am trying to clear the screen in my program.
1. What screen? Who says there is one?
2. Which screen? Who says there is only one?

ANSI C does not require a screen. Having stdin and stdout connected
to an ASR-33 teletype meets the requirements (what few there are
in this respect) of ANSI C. There is *NO* ANSI C solution to your
problem.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.


How does one even try clear the screen on a terminal that prints
on paper? Is this the screen that prevents dirt from clogging up
the bathtub drain?

Gordon L. Burditt
Nov 13 '05 #11

P: n/a
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


On Sat, 06 Dec 2003 09:22:04 -0800, ritchie wrote:
Hi,

I am trying to clear the screen in my program.
I am loking for something that will work on all compilers, especially
Borland & MS Visual Studio 6.
On Visual studio I used 'system("cls");' and this works fine but this
won't work for Borland.
On Borland I used 'clrscr() ' function and it worked ok, but not for
Visual Studio.

Is there anything that will clear the screen in both and maybe also
work on gcc?
In Borland I want to use 'easywin.exe' instead of the console window
and clear the screen.

I thought that 'system("cls");' would work with this?

Any ideas?

Thanks in advance,
Ritchie


Nov 13 '05 #12

P: n/a
Morris Dovey wrote:

Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(
Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


I just hope nobody here has an automated sawmill.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.

--
Les Cargill
Nov 13 '05 #13

P: n/a
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


Please don't top-post, and please don't post non-portable answers. This
groups is for the C language, not for tricks that won't even work on
most platforms. This is in the FAQ:

http://www.eskimo.com/~scs/C-faq/q19.4.html

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Nov 13 '05 #14

P: n/a
CBFalconer wrote:
Richard Heathfield wrote:
CBFalconer wrote:
> Since you carefully read the FAQ, you are now aware that this
> cannot be done in standard C. About the closest you can come is:
^^^^^^^
>
> puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n");
>
> and you may need to adjust the \n count.


And that (as you know) isn't a portable technique either.


Note underlined word above :-)
> After all that, don't do it. There is nothing more annoying than
> gratuitious screen clearings from imbecelic programs removing data
> I want to remain visible.


Nothing wrong with clearing the screen (by which I really mean the
current terminal window), as long as he puts the old data back
afterwards. :-)


Disagree. Consider a calculator program. While using it I want
the data that was previously left on my screen.


Clearly, you would not use a calculator that clears your screen, then.
(Neither do I. I keep forgetting that bc doesn't clear the screen, and I'm
always relieved to see that it doesn't, for precisely the reason you gave.)

On the other hand, does your usual source code text editor take full control
over the window in which its output appears? Mine does. And yet I use it
cheerfully.

In other words, it all depends.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #15

P: n/a
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


I tried this on one of my machines at home, and it just printed a little
backward-arrow thing, followed by [J

It certainly didn't clear the screen.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #16

P: n/a
"Richard Heathfield" <do******@address.co.uk.invalid> wrote:
On the other hand, does your usual source code text editor take full
control over the window in which its output appears? Mine does. And
yet I use it cheerfully.


When I invoke my usual source code text editor with a command like:
C:\docs\prog\c>text rheathfield.c
It pops up its own window leaving my shell window intact. That's the
way I like it.

Even when I am forced to use terminal-based screen editors I usually
still open up another terminal window for the editor so that I can
switch from shell prompt to editor quickly without having to close
the editor.

--
Simon.
Nov 13 '05 #17

P: n/a
In article <3F***************@worldnet.att.net>, lc******@worldnet.att.net
says...
Morris Dovey wrote:

Mark McIntyre wrote:
I tried this on my teletype and now my doctor says I'll have to write
wrong-handed till the burns heal. :-(


Worse - I tried it on my CNC router and now I have mortise and
tenon joints...


I just hope nobody here has an automated sawmill.


Well, that computer controlled minigun from an Aegis missile cruiser
we're working on in the lab may not take kindly at all to a clear screen
command.

--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: po********@sco.com
Nov 13 '05 #18

P: n/a
Andrew Robert wrote:
Try using the following:

#define CLRSCRN fprintf ( stdout,"\033[J" )

When you want to clear the screen, all you need to do is

CLRSCRN;


My Volker Craig VC4404 just went into INSERT mode, and displayed a bunch of
funny characters. OTOH, my ASR33 teletype just printed [J

Oh, and it didn't do anything for my 3277 display.
--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.

Nov 14 '05 #19

P: n/a
In <3f***********************@news.free.fr> Bruno Desthuilliers <bd***********@removeme.free.fr> writes:
CBFalconer wrote:
(snip)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic


Is that a true, out-of-the-dictionnary english word ? (sorry, I don't
have my english dictionnary with me - she went to bed early tonight !-)


What is a "dictionnary"? ;-) And English is *always* spelled with a
capital E.

Before pointing out other people's typos/misspellings, check yours!

The proper spellings are "imbecilic" and "dictionary".

Dan

P.S. http://www.m-w.com seldom goes to bed ;-)

--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #20

P: n/a
Bruno Desthuilliers wrote:
CBFalconer wrote:
(snip)
After all that, don't do it. There is nothing more annoying than
gratuitious screen clearings from imbecelic


Is that a true, out-of-the-dictionnary english word ? (sorry, I don't
have my english dictionnary with me - she went to bed early tonight !-)


Typo. Try imbecilic.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.