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

screen clearing in ANSI C

P: n/a
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu
Nov 24 '06 #1
Share this Question
Share on Google+
65 Replies


P: n/a
Leslie Kis-Adam wrote:
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
No, "screens" are platform specific and may not even exist in many.

--
Ian Collins.
Nov 24 '06 #2

P: n/a

Leslie Kis-Adam wrote:
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu
printf(" \033[2J");

should do the work, it's an ansi code for clear screen

Nov 24 '06 #3

P: n/a
st******@gmail.com said:
>
Leslie Kis-Adam wrote:
>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu

printf(" \033[2J");

should do the work, it's an ansi code for clear screen
I wrapped it up in a main and ran it on my Linux box, but the screen didn't
clear. Not even the terminal window cleared.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 24 '06 #4

P: n/a
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
..
..
..
system("cls");
..
..
..
}

This syntax is what I have been using over the years, however, you have
to find the proper spot to place this syntax.

kind regards,
Gurdip Singh.
gu****@hackinthebox.org || gu*************@gmail.com

Nov 24 '06 #5

P: n/a
gurdz wrote:
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
system("cls");
Platform (windows?) specific.

--
Ian Collins.
Nov 24 '06 #6

P: n/a
In article <11**********************@m7g2000cwm.googlegroups. com>,
gurdz <gu*************@gmail.comwrote:
>If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
>system("cls");
I tried that, but unfortunately the "cls" command on my system means
"clear local storage", and it reformatted all my disks.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 24 '06 #7

P: n/a
"Leslie Kis-Adam" writes:
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
A for loop containing about 60 '\n's would clear most, but not all,
screens.
Nov 24 '06 #8

P: n/a
gurdz wrote:
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
..
..
..
system("cls");
..
..
..
}

This syntax is what I have been using over the years, however, you have
to find the proper spot to place this syntax.
Hmm, when I run the following program, it outputs:
"sh: line 1: cls: command not found"

#include <stdlib.h>

int main()
{
system("cls");
return 0;
}
--
Clark S. Cox III
cl*******@gmail.com
Nov 25 '06 #9

P: n/a
>Hi everyone!
>Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Where is the screen on my ASR33 teletype? Or do you mean the metal
screen that keeps flies from getting sucked into the fan on the back of
the CPU unit? For that one, you power down the CPU, remove the screen,
and blast it with a stream of water from a hose to wash the flies off.
Nov 25 '06 #10

P: n/a
On Sat, 25 Nov 2006 11:43:57 +1300, Ian Collins <ia******@hotmail.com>
wrote:
>Leslie Kis-Adam wrote:
>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?

No, "screens" are platform specific and may not even exist in many.
It simply can't be done in ANSI C. The most portable and reliable
method is to remove power.

--
Dan Henry
Nov 25 '06 #11

P: n/a
Leslie Kis-Adam wrote:
>
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Yes, I know. No, it isn't.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 25 '06 #12

P: n/a
st******@gmail.com wrote:
Leslie Kis-Adam wrote:
>Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?

printf(" \033[2J");

should do the work, it's an ansi code for clear screen
Doesn't work on my ASR33 teletype.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 25 '06 #13

P: n/a
system ("cls") works for me....

i will provide you with a simple program that uses it when i get back
on.. right now i gotta head for classes..thats right. classes on
saturday...

kind regards,
Gurdip

Nov 25 '06 #14

P: n/a
gurdz wrote:
system ("cls") works for me....

i will provide you with a simple program that uses it when i get back
on.. right now i gotta head for classes..thats right. classes on
saturday...
You should provide some context when replying. This is not Google
Groups. This is Usenet.

The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Nov 25 '06 #15

P: n/a
Then your Lunix doesn't support ANSI escape codes

http://en.wikipedia.org/wiki/ANSI_escape_code

Richard Heathfield wrote:
st******@gmail.com said:

Leslie Kis-Adam wrote:
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu
printf(" \033[2J");

should do the work, it's an ansi code for clear screen

I wrapped it up in a main and ran it on my Linux box, but the screen didn't
clear. Not even the terminal window cleared.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #16

P: n/a
[Top-posting fixed]

st******@gmail.com said:
Richard Heathfield wrote:
>st******@gmail.com said:
Leslie Kis-Adam wrote:
Does anyone know, if it is possible to clear the screen in ANSI C?

printf(" \033[2J");

should do the work, it's an ansi code for clear screen

I wrapped it up in a main and ran it on my Linux box, but the screen
didn't clear. Not even the terminal window cleared.
Then your Lunix
Linux
doesn't support ANSI escape codes
Actually, it does, so that wasn't the problem. There was something *else*
you didn't take into account. But yes, that *might* have been the problem,
mightn't it? So that's at least two problems with your suggested technique,
and I humbly suggest that your suggested technique is therefore not
adequate to the task.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #17

P: n/a
Ian Collins said:
gurdz wrote:
>If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
system("cls");

Platform (windows?) specific.
Works fine in MS-DOS, too (unless you've hacked COMMAND.COM, of course). But
yes.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #18

P: n/a
osmium said:
"Leslie Kis-Adam" writes:
>Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?

A for loop containing about 60 '\n's would clear most, but not all,
screens.
For example, it wouldn't clear anything off a non-scrolling terminal. It
wouldn't clear anything off a teletype. It wouldn't clear anything off a
window other than the current window (on a multi-window system). It
wouldn't clear anything off a screen if stdout is not associated with that
screen (which isn't necessarily under the control of the program). In fact,
there are so many ways this won't work that I'm surprised you bother to
suggest it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #19

P: n/a
Dan Henry said:
On Sat, 25 Nov 2006 11:43:57 +1300, Ian Collins <ia******@hotmail.com>
wrote:
>>Leslie Kis-Adam wrote:
>>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?

No, "screens" are platform specific and may not even exist in many.

It simply can't be done in ANSI C. The most portable and reliable
method is to remove power.
Peter Seebach may well have serious objections to that suggestion (since he
claims to be a conforming implementation).

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #20

P: n/a
sq

"Leslie Kis-Adam д
"
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu
sorry ,I do not know~

Nov 25 '06 #21

P: n/a


On Nov 25, 7:04 am, "gurdz" <gurdipsgandh...@gmail.comwrote:
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
.
.
.
system("cls");
.
.
.

}This syntax is what I have been using over the years, however, you have
to find the proper spot to place this syntax.

kind regards,
Gurdip Singh.
gur...@hackinthebox.org || gurdipsgandh...@gmail.com
I know a little about it. There seems to be no such an ANSI function to
do this kind of work.
The function "system("cls")" just calls the shell to execute that
command. So the shell command inside that function is system specific.
"cls" is probably used in MS-DOS. And therefore, "clear" is for most
UNIX/Linux like systems. It's just shell command:-)

Nov 25 '06 #22

P: n/a
ive been using system("cls")
works fine on my windows system but i think it wont wrk on a linux box
bcoz its a shell command for Dos!!

On Nov 25, 12:48 pm, "Becker" <weichao...@gmail.comwrote:
On Nov 25, 7:04 am, "gurdz" <gurdipsgandh...@gmail.comwrote:
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
.
.
.
system("cls");
.
.
.
}This syntax is what I have been using over the years, however, you have
to find the proper spot to place this syntax.
kind regards,
Gurdip Singh.
gur...@hackinthebox.org || gurdipsgandh...@gmail.comI know a little about it. There seems to be no such an ANSI function to
do this kind of work.
The function "system("cls")" just calls the shell to execute that
command. So the shell command inside that function is system specific.
"cls" is probably used in MS-DOS. And therefore, "clear" is for most
UNIX/Linux like systems. It's just shell command:-)
Nov 25 '06 #23

P: n/a

gurdz wrote:
system ("cls") works for me....
Good for you. What's that got to do with the question?

Nov 25 '06 #24

P: n/a
"Richard Tobin" <ri*****@cogsci.ed.ac.ukwrote in message
news:ek**********@pc-news.cogsci.ed.ac.uk...
In article <11**********************@m7g2000cwm.googlegroups. com>,
gurdz <gu*************@gmail.comwrote:
>>If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
>>system("cls");

I tried that, but unfortunately the "cls" command on my system means
"clear local storage", and it reformatted all my disks.
:O Sue him!

lol...
Nov 25 '06 #25

P: n/a
rhle.freak wrote:
ive been using system("cls")
You've been playing dice.
works fine on my windows system
but i think it wont wrk on a linux box
bcoz its a shell command for Dos!!
Why don't you try Linux and find out instead of silly assumptions?

Nov 25 '06 #26

P: n/a
gurdz wrote:
If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
{
.
.
.
system("cls");
.
.
.
}
Completely non-portable. Assumes the existence of a host system, a
command called 'cls' and that the said command clears the screen, no
more no less.
This syntax is what I have been using over the years, however, you have
to find the proper spot to place this syntax.
It's a call to a function, not a syntax.

Nov 25 '06 #27

P: n/a
st******@gmail.com wrote:

Your reply should ideally be in between or after the quoted text, as
otherwise, it affects the reading order for other posters.
Richard Heathfield wrote:
st******@gmail.com said:
Leslie Kis-Adam wrote:
>Hi everyone!
>Does anyone know, if it is possible to clear the screen in ANSI C?
>If it is,then how?
>Any help would be appreciated.
>>
>Laszlo Kis-Adam
><dfighter_AT-NOSPAM_freemail.hu
>
printf(" \033[2J");
>
should do the work, it's an ansi code for clear screen
I wrapped it up in a main and ran it on my Linux box, but the screen didn't
clear. Not even the terminal window cleared.

Then your Lunix doesn't support ANSI escape codes

http://en.wikipedia.org/wiki/ANSI_escape_code
Nor does standard C. Why make your program needlessly non-portable,
especially given that clearing the screen is not important to most
console programs?

Nov 25 '06 #28

P: n/a
santosh said:

<snip>
Why make your program needlessly non-portable,
especially given that clearing the screen is not important to most
console programs?
C isn't only useful for console programs, and clearing a screen (or, more
commonly nowadays, a window) can be a useful thing to do. It is not
unreasonable to ask whether an ISO C method exists (although of course we
know the answer is that it doesn't, and that an implementation-specific
method will need to be used).

Yes, you're right that a great many people seem to delight in clearing the
screen for no particularly good reason. But the OP *might* have a good
reason for asking - you never know your luck! - so the best thing to do, I
suppose, is simply to explain the fact that the method will vary from
system to system, so he should abstract out the non-portable functionality
into a separate function, and then write various versions of that function
on an implementation-by-implementation basis.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 25 '06 #29

P: n/a

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:iL********************@bt.com...
santosh said:

<snip>
>Why make your program needlessly non-portable,
especially given that clearing the screen is not important to most
console programs?

C isn't only useful for console programs, and clearing a screen (or, more
commonly nowadays, a window) can be a useful thing to do. It is not
unreasonable to ask whether an ISO C method exists (although of course we
know the answer is that it doesn't, and that an implementation-specific
method will need to be used).

Yes, you're right that a great many people seem to delight in clearing the
screen for no particularly good reason. But the OP *might* have a good
reason for asking - you never know your luck! - so the best thing to do, I
suppose, is simply to explain the fact that the method will vary from
system to system, so he should abstract out the non-portable functionality
into a separate function, and then write various versions of that function
on an implementation-by-implementation basis.
What I need is a function that will clear my desk.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.

Nov 25 '06 #30

P: n/a
i dont giv a damn.i know it wont wrk ..its a shell command for dos ,not
for linux :-x!!

On Nov 25, 5:04 pm, "santosh" <santosh....@gmail.comwrote:
rhle.freak wrote:
ive been using system("cls")You've been playing dice.
works fine on my windows system
but i think it wont wrk on a linux box
bcoz its a shell command for Dos!!Why don't you try Linux and find out instead of silly assumptions?
Nov 25 '06 #31

P: n/a
rhle.freak wrote:
ive been using system("cls")
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or:
<http://www.caliburn.nl/topposting.html>
Nov 25 '06 #32

P: n/a

Nelu wrote:
gurdz wrote:
system ("cls") works for me....

i will provide you with a simple program that uses it when i get back
on.. right now i gotta head for classes..thats right. classes on
saturday...

You should provide some context when replying. This is not Google
Groups. This is Usenet.
I thought that giving context coming at usenet through google would be
hard. It is not.
The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS

Nov 25 '06 #33

P: n/a
On 24 Nov 2006 15:04:29 -0800, in comp.lang.c , "gurdz"
<gu*************@gmail.comwrote:
>If I'm not wrong, the simplest method of clearing the screen would be
to use a syntax as shown below
.
system("cls");
-bash: cls: command not found

(note: posting system-specific responses in CLC will get you flamed).

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Nov 25 '06 #34

P: n/a
On Fri, 24 Nov 2006 23:34:22 +0100, in comp.lang.c , Leslie Kis-Adam
<df******@freemail.huwrote:
>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
You know this is a FAQ, right?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Nov 25 '06 #35

P: n/a
lane straatman wrote:
Nelu wrote:
><snip>
The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS
My argument was that what he did was implementation dependent and
it was not off-topic. I hope your argument was intended as a
joke, otherwise you're just trolling and I wasted my time replying.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Nov 25 '06 #36

P: n/a
lane straatman said:
Nelu wrote:
>The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux.
Yes. It's also just another reason to steer clear of Macs, mainframes,
minicomputers, games consoles, set-top boxes, microwave ovens, and indeed
just about anything that has some kind of display screen but which doesn't
happen to run MS-DOS or Windows. Your world is tiny, but it's safe.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 26 '06 #37

P: n/a
"lane straatman" <gr**********@netzero.netwrote in message
>
>The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS
Absolutely. Join my campaign for 64-bit ints.

One world,
One race,
One true religion
One vision.

One OS, one way of representing integers.

--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Nov 26 '06 #38

P: n/a

"Dan Henry" <us****@danlhenry.comwrote in message
news:ct********************************@4ax.com...
On Sat, 25 Nov 2006 11:43:57 +1300, Ian Collins <ia******@hotmail.com>
wrote:
>>Leslie Kis-Adam wrote:
>>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?

No, "screens" are platform specific and may not even exist in many.

It simply can't be done in ANSI C. The most portable and reliable
method is to remove power.
A friend of mine wrote an adventure featuring an LCD laptop with a run-down
battery and the last inputs frozen on the screen.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Nov 26 '06 #39

P: n/a
Malcolm wrote:
"lane straatman" <gr**********@netzero.netwrote in message
The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS
Absolutely. Join my campaign for 64-bit ints.

One world,
One race,
One true religion
One vision.

One OS, one way of representing integers.
.... and One Standard for C.
Oops, which one?

Nov 26 '06 #40

P: n/a
Mark McIntyre wrote:
On Fri, 24 Nov 2006 23:34:22 +0100, in comp.lang.c , Leslie Kis-Adam
<df******@freemail.huwrote:
>Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?

You know this is a FAQ, right?
I've found it out!

--
Leslie Kis-Adam or
Laszlo Kis-Adam or even
Kis-dm Lszl

Student
Budapest University of Technology and Economics
Faculty of Electronic Engineering and Computer Science
<dfighter_AT_NOSPAM_freemail.hu>
Nov 26 '06 #41

P: n/a
Does anyone know, if it is possible to clear the screen in ANSI C?

On platforms that have "glass teletype" screens, it is usually
possible to send the terminal a "clear screen" message without
violating any of the rules on ANSI C.
If it is,then how?
Platform-specific escape codes, usually. On other platforms there will
be a command executable with the system() function.

If you meant "is it possible to *portably* clear the screen in ANSI
C?", the answer is no.

--Joel

Nov 26 '06 #42

P: n/a
st******@gmail.com wrote:
Then your Lunix doesn't support ANSI escape codes
If you’re referring to lunix, then you ought to be using Ken’s C
compiler and not worrying about ANSI… ☺

--Joel

Nov 26 '06 #43

P: n/a
"santosh" <sa*********@gmail.comwrote in message
Malcolm wrote:
>"lane straatman" <gr**********@netzero.netwrote in message
>
The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS
Absolutely. Join my campaign for 64-bit ints.

One world,
One race,
One true religion
One vision.

One OS, one way of representing integers.

... and One Standard for C.
Oops, which one?
A failed standard is a huge problem.
The only answer is to be very conservative.
However the other day I found myself needing nans to represent uninitialised
numbers in my new BASIC interpreter. So I swallowed hard and put is an
_isnan() from Microsoft. Also I wanted a vnsprintf in some config file
reading code, soon to be posted.
The question is, is it better to have a potential security hole or a
potential unsupported dependency? Or should I add lines and lines of code
checking every argument, which invilves parsing a printf format string? Or
just make the interface harder to use?
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Nov 26 '06 #44

P: n/a
Malcolm wrote:
"santosh" <sa*********@gmail.comwrote in message
Malcolm wrote:
"lane straatman" <gr**********@netzero.netwrote in message

The request was for ANSI C. Wanna bet that that call won't clear
the screen on my Linux machine even though it will probably
compile correctly?
Just another reason to steer clear of linux. LS

Absolutely. Join my campaign for 64-bit ints.

One world,
One race,
One true religion
One vision.

One OS, one way of representing integers.
... and One Standard for C.
Oops, which one?
A failed standard is a huge problem.
The only answer is to be very conservative.
....
The question is, is it better to have a potential security hole or a
potential unsupported dependency?
In nearly all cases the latter is better, particularly if you clearly
document the dependency. It shouldn't be too much of a problem for
users of the program to download the correct version as well as any
dependencies.
Or should I add lines and lines of code
checking every argument, which invilves parsing a printf format string? Or
just make the interface harder to use?
Your call, (and I suppose it'll vary on a case by case basis,
especially depending upon the program's target user base's skill
level), but the trend for a decade now has been to make the software
"user friendly", at the cost of the programmer and portability.

Nov 27 '06 #45

P: n/a
In article <11**********************@j72g2000cwa.googlegroups .com>,
st******@gmail.com writes
>Then your Lunix doesn't support ANSI escape codes

http://en.wikipedia.org/wiki/ANSI_escape_code

This is where Wiki gets dangerous. Any damned fool can write it.

Linux, Unix, Dos, windows, VMX, VAX, CPM , MPM, OS9, PSOS etc etc have
terminal windows. (Even if in the case of DOS it is only one large
terminal window)

They use terminal drivers. Two of the more common are VT100 and VT52.
However there are many others.

What is the terminal type you are trying to clear screen on?

BTW this is WAY off topic for C.L.C
>
Richard Heathfield wrote:
>st******@gmail.com said:
>
Leslie Kis-Adam wrote:
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu

printf(" \033[2J");

should do the work, it's an ansi code for clear screen

I wrapped it up in a main and ran it on my Linux box, but the screen didn't
clear. Not even the terminal window cleared.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 27 '06 #46

P: n/a
In article <11*********************@m7g2000cwm.googlegroups.c om>,
santosh <sa*********@gmail.comwrites
>st******@gmail.com wrote:

Your reply should ideally be in between or after the quoted text, as
otherwise, it affects the reading order for other posters.
>Richard Heathfield wrote:
st******@gmail.com said:
Leslie Kis-Adam wrote:
Hi everyone!
Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?
Any help would be appreciated.

Laszlo Kis-Adam
<dfighter_AT-NOSPAM_freemail.hu

printf(" \033[2J");

should do the work, it's an ansi code for clear screen

I wrapped it up in a main and ran it on my Linux box, but the screen didn't
clear. Not even the terminal window cleared.

Then your Lunix doesn't support ANSI escape codes

http://en.wikipedia.org/wiki/ANSI_escape_code

Nor does standard C. Why make your program needlessly non-portable,
especially given that clearing the screen is not important to most
console programs?
If yopu have a screen you will need to clear it at some point. You have
to use the escape codes for that VT

What to you meed by "needlessly non-portahble? The only way o0f making
it completely portable is having no screen.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 27 '06 #47

P: n/a
In article <4s************@mid.individual.net>, osmium
<r1********@comcast.netwrites
>"Leslie Kis-Adam" writes:
>Does anyone know, if it is possible to clear the screen in ANSI C?
If it is,then how?

A for loop containing about 60 '\n's would clear most, but not all,
screens.
That is not a"clear screen."

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 27 '06 #48

P: n/a

santosh wrote:
Your call, (and I suppose it'll vary on a case by case basis,
especially depending upon the program's target user base's skill
level), but the trend for a decade now has been to make the software
"user friendly", at the cost of the programmer and portability.
"user friendly" went from meaning to have a powerful tool that you need
to learn to use to having a somewhat "has to work out of the box
without even understanding what it does".
I would rather say "user knowledge overriding" software.

Thomas

Nov 27 '06 #49

P: n/a
Malcolm wrote:
>
What I need is a function that will clear my desk.
Take the mechnism from one of those self-cleaning
kitty-litter boxes, and mount it to your desk.
It will then automatically clear your desk after
each use.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 27 '06 #50

65 Replies

This discussion thread is closed

Replies have been disabled for this discussion.