Question 19.4

How can I clear the screen?
How can I print things in inverse video?
How can I move the cursor to a specific x, y position?


Such things depend on the terminal type (or display) you're using. You will have to use a library such as termcap, terminfo, or curses, or some system-specific routines, to perform these operations.

For clearing the screen, a halfway portable solution is to print a form-feed character ('\f'), which will cause some displays to clear. Even more portable would be to print enough newlines to scroll everything away. As a last resort, you could use system (see question 19.27) to invoke an operating system clear-screen command.

References: PCS Sec. 5.1.4 pp. 54-60, Sec. 5.1.5 pp. 60-62


Read sequentially: prev next up top


This page by Steve Summit // Copyright 1995 // mail feedback