c or c++ program to excute at a specified time

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 1
Reputation: ranjithgoud is an unknown quantity at this point 
Solved Threads: 0
ranjithgoud's Avatar
ranjithgoud ranjithgoud is offline Offline
Newbie Poster

c or c++ program to excute at a specified time

 
0
  #1
19 Days Ago
hi guys,
i am ranjith intrested in writing c c++ progs i hav a doubt that can i write a c or c++ program to excute at a given time

thanks
Last edited by ranjithgoud; 19 Days Ago at 5:14 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 113
Reputation: abhi_elementx is an unknown quantity at this point 
Solved Threads: 5
abhi_elementx's Avatar
abhi_elementx abhi_elementx is offline Offline
Junior Poster
 
0
  #2
19 Days Ago
Originally Posted by ranjithgoud View Post
hi guys,
i am ranjith intrested in writing c c++ progs i hav a doubt that can i write a c or c++ program to excute at a given time

thanks
Yes you can.
See the system() function for more information.

Cheers
PEACE !
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 116
Reputation: marco93 is infamous around these parts marco93 is infamous around these parts marco93 is infamous around these parts 
Solved Threads: 12
marco93 marco93 is offline Offline
Junior Poster
 
0
  #3
19 Days Ago
Originally Posted by abhi_elementx View Post
Yes you can.
See the system() function for more information.
Cheers

???
system() has nothing to do there (it's even prohibited under Windows...)
Just use the scheduler
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 113
Reputation: abhi_elementx is an unknown quantity at this point 
Solved Threads: 5
abhi_elementx's Avatar
abhi_elementx abhi_elementx is offline Offline
Junior Poster
 
0
  #4
19 Days Ago
Originally Posted by marco93 View Post
???
system() has nothing to do there (it's even prohibited under Windows...)
Just use the scheduler
You are definitely right. But i gotta justify my reply.
The poster wanted to ask if he can call exes at given time.
For this the he can write a code to call his exes.

The scheduler does schedule execution of the exes. But what i replied was related to 'through code' .

system() call is very much 'allowed' in Windows(If u meant that the system() call in Win environment is not allowed).
I use Dev-C++ on Win Xp and use the system("PAUSE") call to pause the program just before it passes control to the OS.

system() can certainly invoke exes:
http://www.computing.net/answers/pro...app/16725.html
http://www.cplusplus.com/reference/c...stdlib/system/


Cheers
PEACE !
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 5
Reputation: suresh1010 is an unknown quantity at this point 
Solved Threads: 0
suresh1010 suresh1010 is offline Offline
Newbie Poster

hiii

 
0
  #5
19 Days Ago
this wil be possible once your code is in exe mode. Once the time fixed crosses, the desired procdure may be called. Else you may have to seek the help of the .bat file
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,810
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #6
19 Days Ago
Originally Posted by ranjithgoud View Post
hi guys,
i am ranjith intrested in writing c c++ progs i hav a doubt that can i write a c or c++ program to excute at a given time

thanks

You're going to have to clarify. Do you have some executable program, originally written in C++, that you want to run at, say 2 p.m.? All sorts of languages can be used to cause this to happen, not just C++, and you don't need to write your own. As mentioned, the Operating System can handle this for you with no code written by you (i.e. the scheduler, as mentioned). Or are you trying to write a program in C++ that will run an executable program at a specified time (i.e. are you WRITING a scheduler program in C++)?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 113
Reputation: abhi_elementx is an unknown quantity at this point 
Solved Threads: 5
abhi_elementx's Avatar
abhi_elementx abhi_elementx is offline Offline
Junior Poster
 
0
  #7
18 Days Ago
True. You actually actually schedule any exe(application), written in any of the languages for that matter.
PEACE !
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 15
Reputation: kim00000 is an unknown quantity at this point 
Solved Threads: 0
kim00000 kim00000 is offline Offline
Newbie Poster
 
0
  #8
13 Days Ago
Hello ,Ranjith!

Try This:

  1. #include <iostream> // For Simple Input & Output.
  2. #include <time.h> // For dealing with time.
  3. #include <conio.h> // For getch() function.
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. struct tm T;
  10. _getsystime( &T );
  11.  
  12. if (T.tm_hour == 12) // If the Time is 12 PM.
  13. {
  14. cout << "Sorry this programme can't be executed at this time";
  15. getch();
  16. return 0;
  17. }
  18. else
  19. {
  20. goto Programme;
  21. }
  22.  
  23. Programme:
  24. //Your Programme Here
  25. }

I think it should work with you ,Because i tryed it before posting and it worked well...

Regards,,
Kimo.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC