Solved

time_t / difftime in millisconds

Posted on 1997-09-16
6
4,046 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
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 50 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-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.

864 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now