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

Timers to take msg

P: 58
Hi all,

I newbe for using a timers.
my requirement is when i enter a message name like " start " ,If it doesn't start in the particular time e.g in 20 seconds then it show the a dilaog box or any printf like start function is not start.

please help me i need your help..........

really any type suggestion is appricited..

thank you..

-Raju
Dec 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: 11
this is a function for a timer:

Expand|Select|Wrap|Line Numbers
  1. void sleep(unsigned int mseconds){
  2.      clock_t goal = mseconds + clock();
  3.      while (goal > clock());
  4. }
usage:

Expand|Select|Wrap|Line Numbers
  1. printf("The program is now waiting 5 seconds and will start the program after");
  2. sleep(5000)
  3. startprogram();
  4.  
  5. if (variable == 1){
  6.   printf("It started");
  7. }else{
  8.   printf("It hasn't started");
  9. }
  10.  
  11. // get something in the function startprogram() to set a variable to 1
  12. // 5000 is the milliseconds the program waits so 5000 = 5 seconds.
// when sleep is running you can't do anything else!

I don't know if that's what you actually meant, maybe you should try it out.
Dec 19 '06 #2

Post your reply

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