kph1
asked on
time_t / difftime in millisconds
Does anyone have a function in ANSI C that breaks down the time_t and difftime functions into milliseconds instead of seconds? I am running it on a dos platform based machine.
time_t cannot be broken down into milliseconds. It is a integer count of seconds, and does not have a resolution smaller than seconds. What operating system are you using?
ASKER
Edited text of question
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you were under WIn95 or WinNT you could use timeGetTime (part of the multimedia API) which is down to milliseconds.
I think functions that do better than that are dependant on the hardware etc.
I think functions that do better than that are dependant on the hardware etc.
Also have a look at the C FAQ questions:
19.37: How can I implement a delay, or time a user's response, with sub-second resolution?
19.37: How can I implement a delay, or time a user's response, with sub-second resolution?
You can use the function ftime.
#include <sys/time.h>
int ftime(
struct timeb *tp );
The struct timeb contains a field millitm with the milliseconds.
jolusg
#include <sys/time.h>
int ftime(
struct timeb *tp );
The struct timeb contains a field millitm with the milliseconds.
jolusg