473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

question concerning screen control

My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

Please enlighten me, thanks for your time.
Nov 14 '06 #1
10 1717
In <45**********************@news.mindlink.netKenne th Lantrip <bo********@cmaaccess.comwrites:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
If you're *really* talking about standard C, then no. Standard C has no
concept of a "screen".

If you're willing to be somewhat non-portable, your compiler might have
a clrscr() function.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
They're fairly standard, yes. I'd try googling for "ansi escape
sequences."

Or if there is a "curses" package available for your platform, you
might use that.

--
John Gordon "... What with you being his parents and all,
go****@panix.com I think that you could be trusted not to shaft
him." -- Robert Chang, rec.games.board

Nov 14 '06 #2
Kenneth Lantrip <bo********@cmaaccess.comwrites:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
No. See the comp.lang.c FAQ, <http://www.c-faq.com/>, question 19.4.

A formfeed character, '\f', will *not* clear the screen on many
systems.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '06 #3
>My question is: Is there a generally accepted way to clear the screen
>and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Not in Standard C. A number of systems have the "curses" library
which deals with this.
>What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
ANSI control codes only work if the serial terminal or emulation
thereof honors them. So if the program is running on a computer
connected to a dialup line, you're out of luck if the guy is dialing
up with an ASR 33 Teletype or some kind of CRT without ANSI codes.
Also, the terminal emulation in the MS-DOS console is pretty crude
and doesn't do ANSI control codes unless you load ANSI.SYS.

The curses library depends on the user telling the library what type of
terminal it is using, and matching it to a description of the control
codes to use, and the library adapts accordingly.

Lots of terminal emulators emulate ANSI codes. If you *must* hardcode
escape sequences, those are the ones to use. That's not saying much.
>Please enlighten me, thanks for your time.

Nov 15 '06 #4
go***********@burditt.org (Gordon Burditt) writes:
>>My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

Not in Standard C. A number of systems have the "curses" library
which deals with this.
<OT>
curses is probably overkill if all you want to do is clear the screen.
In some modes of operation, a program that uses curses will restore
the screen's previous contents on exit (though you can probably avoid
that).
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '06 #5
Kenneth Lantrip wrote:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Not within standard C, no. You might try printing a formfeed character,
'\f', or several newlines, but these are all half-baked solutions.
Again, there's no way to move the cursor to a particular line, without
making a lot of unwarrented assumptions.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?
They're fairly widespread but are by no means guarenteed to be present.
Please enlighten me, thanks for your time.
If you're program _really_ needs screen control, then using the curses
package is a good option. It's widely implemented across UNIXes,
Windows and Mac. It is a better option than using ANSI control
sequences, which are lower level. Of course, for a specific platform,
often better, more feature-rich libraries are available, but you'll
have to ask such questions in more specific newsgroups.

Nov 15 '06 #6
John Gordon <go****@panix.comwrote:
In <45**********************@news.mindlink.netKenne th Lantrip <bo********@cmaaccess.comwrites:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

If you're *really* talking about standard C, then no. Standard C has no
concept of a "screen".

If you're willing to be somewhat non-portable, your compiler might have
a clrscr() function.
s/somewhat/more than somewhat/.
What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

They're fairly standard, yes. I'd try googling for "ansi escape
sequences."
And don't be surprised when people turn that feature off because it can
be used to aggravate, and then tell you that your program looks crap and
leaves random letters all over the screen.
Or if there is a "curses" package available for your platform, you
might use that.
That's probably the solution most likely to work in many places. At
least it has been ported a lot.

Richard
Nov 15 '06 #7
Kenneth Lantrip <bo********@cmaaccess.comwrites:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?
Apart from the fact that there's no really portable way to do this,
consider whether you really want to clear the screen. If your
application really needs to take control of the screen (like, say, a
text editor), that's fine, and you probably want to use something
similar to curses. But don't clear the screen just for the sake of
clearing the screen; I don't want *your* program to erase *my*
information without a good reason.

(The fact that you asked about moving the cursor indicates that this
likely doesn't apply to what you're doing, though.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '06 #8
Keith Thompson wrote:
Kenneth Lantrip <bo********@cmaaccess.comwrites:
>>My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?


Apart from the fact that there's no really portable way to do this,
consider whether you really want to clear the screen. If your
application really needs to take control of the screen (like, say, a
text editor), that's fine, and you probably want to use something
similar to curses. But don't clear the screen just for the sake of
clearing the screen; I don't want *your* program to erase *my*
information without a good reason.

(The fact that you asked about moving the cursor indicates that this
likely doesn't apply to what you're doing, though.)
Thanks guys, You all have been most helpful.

I'll give the \f a try. I just wanted to keep the compiling as simple
as possible. I can already use the ncurses library. I was just trying
to get away from any any extra add-ons to make a simple program work.

For what I am about to attempt I will just use the ncurses. I was just
reaching for something more built in so the program would have greater
chance of being operable accross platforms. Scrolling the screen is
out. There is way too much data that needs to be constantly updated for
scrolling. A simple cursor locating would have been nice, as I wouldn't
have to clear your data first.

Oh well, so goes the wishing.
Nov 15 '06 #9
Kenneth Lantrip wrote:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

Please enlighten me, thanks for your time.
Spamming won't help your cause. You've already been sufficiently
answered from within the topicality constraints of this group. What's
the point in duplicating your original post without specifying further
details or including code?

Nov 15 '06 #10
santosh wrote:
Kenneth Lantrip wrote:
My question is: Is there a generally accepted way to clear the screen
and perhaps move the cursor to a new location (other than newline) for
the next printf in standard c?

What about ANSI control codes? Are those standard across most
platforms? Or is that just for PC/MAC based computers? Anyone know
where I can see a list of ANSI codes?

Please enlighten me, thanks for your time.

Spamming won't help your cause...
<snip>

My sincere apologies to Kenneth Lantrip. From here the original post
appeared to have been duplicated. Hence my admittedly acidic response.

Nov 15 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find...
5
by: Peter Rilling | last post by:
Okay, this method seems simple, but it eludes nonetheless. I have a control that is nested in other controls. Essentially the control is nested several contains from the main form. All I want...
1
by: Green | last post by:
Hi, I have a question concerning how to manipulate the properties in the user control, and there is an interesting article about this from Microsoft:...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
5
by: ken | last post by:
Hi, I have two questions the first is: in the example below how can I call an event from within a statement, such as replace Stop1 with cmdStop1 which is a button on my form? My second question...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
12
by: Boris Borcic | last post by:
Hello, I am trying to use UI Automation to drive an MS Windows app (with pywinauto). I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't...
1
by: mail12211 | last post by:
I can't figure out how to do create this screen. I think I need to use a form with subForm(but I'm not sure). Could you direct me to an article. Or give me some advice on how this is done. I...
8
Stang02GT
by: Stang02GT | last post by:
Hello, I have posted a couple different questions in this thread concerning a menu i had been working on. I have run into another snag in the final stages of the development. I have my current...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.