Find the answer to your Linux question:
Results 1 to 4 of 4
hi , i write C program in TC ( turbo C ) . there is a command " clrscr() " to clear the screen. i need equivalent command in linux ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2003
    Location
    x1234
    Posts
    4

    how to clear screen(g++ compiler)


    hi , i write C program in TC ( turbo C ) . there is a command " clrscr() " to clear the screen. i need equivalent command in linux so that i can use that in my program. i am usuing g++ compiler.

    i write





    Code:
    #include<stdio.h>
    #include<conio.h >
    
    void main&#40;&#41;
    
    &#123;
    
      int x;
      
    clrscr&#40;&#41;;     //  what is the equivalent command in linux  and  its   header??? 
    
    printf&#40;"hi"&#41;;
    
    // other codes
    
    getch&#40;&#41;;
    &#125;


    plz give one sample code how to use that?
    thanks [/code]

  2. #2
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    Re: how to clear screen(g++ compiler)

    Quote Originally Posted by ugotamail
    hi , i write C program in TC ( turbo C ) . there is a command " clrscr() " to clear the screen. i need equivalent command in linux so that i can use that in my program. i am usuing g++ compiler.
    a few methods:
    1) Ncurses. This is a C libary and i beleive it may have something there to do what you want.
    2) system() call. "man 3 system", its in stdlib.h IIRC, just call system("clear"); (this may not work, i dont know)
    3) int i; for(i=0; i != 60; i++) printf("\n");

  3. #3
    Just Joined!
    Join Date
    Dec 2003
    Location
    x1234
    Posts
    4
    system("clear");
    yes its working.i have checked it.....thanks

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That's not really the best solution, though. "clear" is just another ncurses program that only uses the clear call from the ncurses library. It's really much cheaper to call the clear function directly from your program instead of forking and execing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •