I need some help with timing in c++. I have never used any ting that needed a timer. I don't evan know if their is a timer for C++. Please help.
I need some help with timing in c++. I have never used any ting that needed a timer. I don't evan know if their is a timer for C++. Please help.
You'll find the standard functions in ctime (time.h). You can find other functions in other libraries, such as platform SDKs, etc... Do a board search too.
Hmm...not sure exactly what you need to be done.
There's a variety of time functions:
-------------------------------------------------------
http://msdn.microsoft.com/library/de...base/sleep.aspCode:Sleep(n);
Halts the program for n number of milliseconds
-------------------------------------------------------
-------------------------------------------------------
http://msdn.microsoft.com/library/de...ttickcount.aspCode:ULONG ticks=GetTickCount();
-------------------------------------------------------Originally Posted by msdn
-------------------------------------------------------
http://msdn.microsoft.com/library/de...imegettime.aspCode:DWORD time=timeGetTime();
Paired with:Originally Posted by msdn
timeBeginPeriod
and
timeEndPeriod
-------------------------------------------------------
-------------------------------------------------------
And a huge list of synchronization functions here:
http://msdn.microsoft.com/library/de..._functions.asp
A timer in languages like javascript can be set to execute a function in a specifed number of seconds in the future. The code sets the timer and continues execution, and when the specified time elapses, the function executes.
Ok, last explination was bad. In C++, I think any program you will need a timer in, will probably have some form of main loop. What I would suggest doing, is using either the libraries mentioned above, or something like SDL, which has timing functions that are fairly precise. Best idea is simply have a vector of "jobs" you cycle through at the begining or end of the loop, and check them against the current time to see if they are ready to go, by checking if their schedualed time is less then or equal too the current time.
EDIT: ah, the libSDL site is working for me again, one sec and Ill check for any links on their timers.
Ok, found it, check this link http://www.libsdl.org/intro/usingtimers.html
Last edited by Xipher; 03-09-2005 at 09:20 PM.
If any part of my post is incorrect, please correct me.
This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.