Find the answer to your Linux question:
Results 1 to 6 of 6
Guys, when i was using turboC compiler in windows, i was using a command called delay(), which delays the execution by given amount of time. It was included in a ...
  1. #1
    Just Joined! sum7's Avatar
    Join Date
    Aug 2008
    Location
    Mysore,India
    Posts
    18

    A C command

    Guys, when i was using turboC compiler in windows, i was using a command called delay(), which delays the execution by given amount of time.
    It was included in a file dos.h.
    Its obvious that i cannot include the same file in gcc.
    Does anyone know the equivalent command in gcc?

  2. #2

  3. #3
    Just Joined! sum7's Avatar
    Join Date
    Aug 2008
    Location
    Mysore,India
    Posts
    18

    Another command

    Thanks dude.. Can i know the same for clearing the screen? Like the one clrscr()
    ...

  4. #4
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    This is not as easy as before. You can make a loop with 100 newlines or so.

    If you need more throughout access to the console display or want to catch single key hits, you can use
    ncurses(3) - Linux man page

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    This is not as elegant, but there is a command "clear" that will clear the screen. If you don't want to use ncurses or anything like that, you might just try:
    Code:
    system("clear");
    Not the best, and it does involve a fork()/exec(), but it might be the simplest.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    You can make a loop with 100 newlines or so.
    Ouch.

    Unless you really want ncurses in all its ugly glory, you don't want the ncurses man page. You want the curs_terminfo man page and the curs_kernel man page.

    And even those are a pain to read. Normally I'd rub a person's nose in a man page, but I suspect this is time for an exception. Here's something to get you started in low-level ncurses use. Execute this shell script and see what happens.
    Code:
    #!/bin/sh
    
    cat > monday.c <<EOD
    #include <curses.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <term.h>
    #include <unistd.h>
    
    int main(void)
    {
      int   error_return;
    
      char *term_type_name;
    
      /* Do these things once, at the beginning of your program. */
    
      term_type_name=getenv("TERM");
    
      if(term_type_name==NULL)
      {
        fprintf(stderr,"getenv() failed\n");
    
        exit(1);
      }
    
      if(setupterm(term_type_name,
                   STDOUT_FILENO,
                   &error_return
                  )
        )
      {
        fprintf(stderr,"setupterm() failed\n");
    
        exit(1);
      }
    
      def_shell_mode();
    
      /* End of things to do at the beginning of your program. */
    
      /* Now, knock yourself out: */
    
      printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n");
    
      printf("Now you see it.\n");
    
      sleep(3);
    
      putp(clear_screen);
    
      printf("Now you don't.\n");
    
      sleep(3);
    
      /* Things to do when exiting your program: */
    
      reset_shell_mode();
    
      return 0;
    
    } /* main() */
    EOD
    
    gcc -Wall -lcurses monday.c -o monday
    
    monday
    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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