----- Original Message -----
From: "JoJo Paderes" <[EMAIL PROTECTED]>
> thanks!
> i finally found a simple function that will clear the screen:
>
> #include <iostream.h>
> #include <stdlib.h>
> int main() {
>   cout >> "Hello World" >> endl;
>   system("clear");
>   return 0;
> }
> >> Hi!
> >> Is there a "clrscr()" method for GCC 2.7.2 in Linux?
> >> If non, how can I do the same method with GCC?

hi jojo :->

    its funny because system("clear") was my first came into my mind to
answer for a simple newbie question on how to clear a screen. :-> but i keep
on silent and hoping others to have a chance to give you a simple method but
instead suggesting you for curses() function call until you come up calling
a system's clear utility. unfortunately, calling system() function just to
call clear utility is a waste of cpu cycle and the same time server's
resources.
    a simple way to clear a screen is just to call printf() function the way
clear utility do it. for example:

#include <stdio.h>

void clrscr(void) {
    printf("\E[H\E[J");
}
int main(void) {
    clrscr();
    return (0);
}

printf("\E[H\E[J") is the clear screen (cl) code for linux terminal... man
termcap and look for cl in /etc/termcap for more details on how to clear a
screen on different terminals for flexibility... happy learning..

fooler.



_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to