How could I make my program to run in predefined time automatically in c?
How could I make my program to run in predefined time automatically in c?
Depends on the platform. Most implementations provide a sleep function of some sort, so you tell your program to wait the required number of seconds until the time arrives, then run the program.
thank to help me. Can u give me the code then I could lear it better.
Sure. Let's say it's 5:00pm now, and you want to run your program at 6:37:43am the following day:
Code:sleep(49063); system("myprogram");
thanks for the help.I hope your help can inprove my depth in c & c++ too
Most decent operating systems have some kind of 'at' function which allows you to specify a time at which a program should be run.
Thanks for the interest.
But I want to know how a user written program(made in c) will run automatically in predefined time. I want to add the c code to run my program automaticaly.Can u tell
me about that?
Sure, look up the time(), localtime(), mktime() and difftime() functions.
- Find out the time now
- Work out the time you want to run at
- Get the difference between the two
- Sleep for that amount
thanks 4 help.
Can u give a example code pls?
You're going to need to do a little better than that. You've been pointed to the appropriate functions and the steps involved, go look them up, read about them, attempt to come up with a solution, and we'll help you when you get stuck, after you've posted a good attempt.