"Partho Choudhury" <partho@ieee.org> wrote in message
news:3dec3df8.0406280144.982c420@posting.google.co m...[color=blue]
> Hi all:
>
> I need to add a snippet which access the system time (upto atleast
> milliseconds) using ANSI std. C++. I cannot use MFC and Win32 APIs in
> my program for now for various reasons. Is there something like this
> in ANSI C++ which allows access up to milliseconds. I know that time.h
> and CTime allow access up to the second level, but I need to work in
> the msec level.[/color]
Nothing in the Standard guarantees that _any_ clock is available. For
example, it is within the Standard to have clock() return (time_t)0 for all
calls. I agree that such an implementation would be a lousy one, but that is
a matter of quality of implementation, not the Standard.
Most C++ systems will provide a clock with resolution of 1 second, but
support of millisecond resolution is far from universal.
The CLOCKS_PER_SEC macro (defined in <time.h>) gives the number of ticks per
second, so you can give a compile-time message that the environment does not
meet the minimum requirements.
If you are willing to use other standards in addition to the C++ standard,
then IIRC - POSIX mandates a clock with millisecond resolution.
HTH
Daniel Pfeffer
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]