Timestamp

Steve Summit scs at adam.pika.mit.edu
Sat Jul 15 11:35:28 AEST 1989


In article <1595 at stl.stc.co.uk> dsr at stl.stc.co.uk (David Riches) writes:
>Has anyone got a timestamp routine, written in C, which has a
>resolution of milliseconds (possibly lower)?

The implementation of such a routine would be highly system-
dependent.  A somewhat standard but little-known routine already
exists which provides what you want: ftime().  It returns a
structure which "contains the time since the epoch in seconds,
[and] up to 1000 milliseconds of more-precise interval."
If your vendor happens to provide an implementation of this
routine, you're in luck; if not, there's not much portable you
can do.  (X3J11 doesn't appear to help, and neither does POSIX,
which I just discovered doesn't endorse ftime, which is a
miserable omission, but not a topic for this newsgroup.)

                                            Steve Summit
                                            scs at adam.pika.mit.edu

P.S. Microsoft supplies ftime() for MS-DOS; the version of TurboC
     I've used doesn't (although later versions may have added it).



More information about the Comp.lang.c mailing list