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

Edited 7 Years Ago by ranjithgoud: n/a

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

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

???
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/programming/c-system-controlling-called-app/16725.html
http://www.cplusplus.com/reference/clibrary/cstdlib/system/


Cheers

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

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++)?

Hello ,Ranjith!

Try This:

#include <iostream> // For Simple Input & Output.
#include <time.h> // For dealing with time.
#include <conio.h> // For getch() function.

using namespace std;

int main()
{
struct tm T;
_getsystime( &T );

if (T.tm_hour == 12) // If the Time is 12 PM.
{
cout << "Sorry this programme can't be executed at this time";
getch();
return 0;
}
else
{
goto Programme;
}

Programme:
//Your Programme Here
}

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

Regards,,
Kimo.

This article has been dead for over six months. Start a new discussion instead.