943,993 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 805
  • C++ RSS
Nov 4th, 2009
0

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

Expand 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
Last edited by ranjithgoud; Nov 4th, 2009 at 5:14 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ranjithgoud is offline Offline
1 posts
since Nov 2009
Nov 4th, 2009
0
Re: c or c++ program to excute at a specified time
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
Reputation Points: 11
Solved Threads: 7
Junior Poster
abhi_elementx is offline Offline
118 posts
since Dec 2007
Nov 4th, 2009
0
Re: c or c++ program to excute at a specified time
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
Reputation Points: -76
Solved Threads: 14
Junior Poster
marco93 is offline Offline
132 posts
since Apr 2008
Nov 4th, 2009
0
Re: c or c++ program to excute at a specified time
Click to Expand / Collapse  Quote originally posted by marco93 ...
???
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
Reputation Points: 11
Solved Threads: 7
Junior Poster
abhi_elementx is offline Offline
118 posts
since Dec 2007
Nov 4th, 2009
0

hiii

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
suresh1010 is offline Offline
5 posts
since Feb 2008
Nov 4th, 2009
0
Re: c or c++ program to excute at a specified time
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++)?
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
Nov 5th, 2009
0
Re: c or c++ program to excute at a specified time
True. You actually actually schedule any exe(application), written in any of the languages for that matter.
Reputation Points: 11
Solved Threads: 7
Junior Poster
abhi_elementx is offline Offline
118 posts
since Dec 2007
Nov 9th, 2009
0
Re: c or c++ program to excute at a specified time
Hello ,Ranjith!

Try This:

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
kim00000 is offline Offline
84 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Apparent flaws in C++
Next Thread in C++ Forum Timeline: Problems with functions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC