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 ...
- 08-24-2008 #1
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?
- 08-24-2008 #2
- 08-24-2008 #3
Another command
Thanks dude.. Can i know the same for clearing the screen? Like the one clrscr()
...
- 08-24-2008 #4
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
- 08-25-2008 #5
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:
Not the best, and it does involve a fork()/exec(), but it might be the simplest.Code:system("clear");DISTRO=Arch
Registered Linux User #388732
- 08-25-2008 #6Ouch.You can make a loop with 100 newlines or so.
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.
Hope this helps.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--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote