Thread: give user time to read messages

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    give user time to read messages

    Code:
    printf("I am doing a routine...");
    system("choice /c:. /t:.,03 /n >NUL");
    If you are doing something in your program that may run very fast on somebody's computer, they might not have time to read the message. They may see a message fly by really quick like, then wonder what your program is doing to their computer. Is there a way to convert the above system call ( forcing choice to continue by default - without the user knowing it ) into something more C-ish? Can you have control over how long a pause will take place, hence giving the user time to read your short -or- long message?

    http://www.cprogramming.com/cboard/s...threadid=15811

    Should I look into this post?
    The world is waiting. I must leave you now.

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > Depends on your OS and compiler

    Windows 98 SE & GCC.
    The world is waiting. I must leave you now.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Something like this
    Code:
    #include <stdio.h>
    #include <time.h>
    #include <conio.h>
    
    void wait_for_key_or_timeout ( int seconds ) {
        clock_t endtime = clock() + seconds * CLOCKS_PER_SEC;
        while ( !kbhit() && ( clock() < endtime ) );
    }
    
    int main ( ) {
        int i;
        for ( i = 0 ; i < 100 ; i++ ) {
            printf( "%d\n", i );
            if ( (i+1) % 25 == 0 ) wait_for_key_or_timeout(3);
        }
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 07:51 PM
  2. need help in time zone
    By Gong in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2007, 04:44 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  5. Need to give user more time
    By Natase in forum C Programming
    Replies: 6
    Last Post: 09-16-2001, 05:21 PM