By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

How to delay the second output

P: 12
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.
Mar 7 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,510
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.
Expand|Select|Wrap|Line Numbers
  1.     clock_t  clock_start;                         /* holds clock start time */
  2.     clock_start = clock(); 
  3.     while (((clock() - clock_start) / CLOCKS_PER_SEC) < 3)
  4.         /* delay 3 seconds*/ ;
  5.  
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.com/reference/clibrary/ctime/clock.html
Mar 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.