Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

time_t / difftime in millisconds

Posted on 1997-09-16
6
Medium Priority
?
4,119 Views
Last Modified: 2006-11-17
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
Comment
Question by:kph1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1254706
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
 

Author Comment

by:kph1
ID: 1254707
Edited text of question
0
 
LVL 4

Accepted Solution

by:
jos010697 earned 100 total points
ID: 1254708
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:rmichels
ID: 1254709
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
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1254710
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
 

Expert Comment

by:jolusg
ID: 7360984
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question