kaushal wrote:

>       Sorry for a very basic question.I would like to know how to clear the
> screen from within a c program without using system("clear") or any of
> the ncurses functions.Can we do this using printf?My program is in raw
> mode so is there any feature available by which I can use the termios
> structure for clearing the screen if it is not possible with printf.Long
> ago when I used work in the dos platform I used conio.h and clrscr()
> rourine.I guess I have to write that clrscr() routine's code itself.Im
> working on a linux machine now.

Unix systems don't have a "screen", they have terminals. Historically,
these would be physical terminals (e.g. vt220s) connected via serial
ports. The Linux kernel uses the keyboard and the graphics card's text
mode to emulate a number of terminals, as well as supporting physical
terminals connected to a serial port (either directly or via modems)
and pseudo-terminals (used by programs which emulate terminals, e.g. 
telnetd, xterm, screen etc).

To clear the terminal's screen (assuming that it's a video terminal;
hardcopy terminals don't have a screen), you have to send the
appropriate control sequence. The exact sequence depends upon the type
of terminal (which can be determined from the value of the TERM
environment variable).

To obtain the correct control sequence, use the terminfo library to
obtain the sequence for the "clear" capability, then send that
sequence to the terminal (i.e. stdout).

See the manpage for setupterm() and tigetstr() for more information.

-- 
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" 
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to