How to delay the second output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lavender
    New Member
    • Feb 2007
    • 12

    How to delay the second output

    What are the command if I want to delay the 2nd output? what the header file I should use in C?

    example:

    Checking printer status....

    (delay 3 seconds)

    Printer is offline. Please on the printer.
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by lavender
    What are the command if I want to delay the 2nd output? what the header file I should use in C?

    example:

    Checking printer status....

    (delay 3 seconds)

    Printer is offline. Please on the printer.
    some versions of C have a non standard delay() function otherwise you can use functions in <time.h>, e.g.
    Code:
        clock_t  clock_start;                         /* holds clock start time */
        clock_start = clock(); 
        while (((clock() - clock_start) / CLOCKS_PER_SEC) < 3)
            /* delay 3 seconds*/ ;
    clock() returns the number of clock ticks since the program started and the while() loop waits until 3 seconds has elapsed, see
    http://www.cplusplus.c om/reference/clibrary/ctime/clock.html

    Comment

    Working...