Solved

time_t / difftime in millisconds

Posted on 1997-09-16
6
4,062 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 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
Independent Software Vendors: 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!

 
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

Suggested Solutions

Title # Comments Views Activity
C#, VS15, StructLayout 1 137
Windows Updates failing due to Diskpart not configured correctly 8 152
Autosar OS Multicore Share Resources confusion ? 2 185
Fill Null values 5 50
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

740 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