• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4172
  • Last Modified:

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.
0
kph1
Asked:
kph1
1 Solution
 
rmichelsCommented:
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?
0
 
kph1Author Commented:
Edited text of question
0
 
jos010697Commented:
rmichels is right. All you can do (I'm talking portability here)
is to give the clock(void) function a try. This function
returns a clock_t value. The <time.h> file defines a manifest
constant CLOCKS_PER_SEC, i.e. every other second, clock()
returns a new value CLOCKS_PER_SEC units higher than the
previous one ...

kind regards,

Jos aka jos@and.nl
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rmichelsCommented:
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.
0
 
RONSLOWCommented:
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?
0
 
jolusgCommented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now