Hey!
Im currently working on a win32 app which needs
a timer, basically I'll set a start time when
it starts and have end time when it stops.
Then I'll calculate the time based on end-start.
What is the best technique to use?
- Mike
Hey!
Im currently working on a win32 app which needs
a timer, basically I'll set a start time when
it starts and have end time when it stops.
Then I'll calculate the time based on end-start.
What is the best technique to use?
- Mike
GetTickCount() returns the number of milliseconds since windows started.
If you have more Windows questions, you can post them in the Windows board.Code:DWORD StartTime = GetTickCount(); DoSomeStuff(); DWORD EndTime = GetTickCount(); DWORD TimeElapsed = EndTime - StartTime;
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
thanks, is there any platform independant
method?
- Mike
Not that I know of...
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
>>thanks, is there any platform independant method?
Similar to GetTickCount() is clock() in <ctime>, it's platform independent, but not as precise as less portable options.
Code:#include <iostream> #include <ctime> using namespace std; int main() { long i = 0; clock_t start = clock(); while (1) { i++; if (clock() >= start + 10) { break; } } cout<<"The counter is -- "<< i <<endl; }
*Cela*