From -1326249435078022967
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,3b2d33f1a39395a6
X-Google-Attributes: gidf78e5,public
From: David R Tribble <dtribble@technologist.com>
Subject: Re: Getting system time
Date: 1999/03/13
Message-ID: <36E9A091.8E626706@technologist.com>#1/1
X-Deja-AN: 454402320
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <Pine.SGI.3.96.990312091120.4086F-100000@aisa>
X-Original-Date: Fri, 12 Mar 1999 17:17:37 -0600
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 921287897 25055 128.250.29.16 (13 Mar 1999 01:18:17 GMT)
Organization: File by pile
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANum8y+EDnX0m9pzZAQEHTAF+JVYqTSdNS/PS3fXV5hAZIiU+ze/MYuny tlQ3qaeYpvqXK5/kh1bLwOKEH8i64ueI =JvtD
Mime-Version: 1.0
NNTP-Posting-Date: 13 Mar 1999 01:18:17 GMT
Newsgroups: comp.std.c++

Robert Batusek wrote:
> Is there any _portable_ (ANSI compatible) C++ possibility to get the
> system time?
> I have tried ftime but it doesn't work together with fstreams.

Use time(), which is declared in <ctime> and <time.h>.  It's the
same as the standard C (C89) library function.  (ftime() is System
V Unix, and is deprecated.)

If you want more precision, you could try a combination of time()
and clock() calls.

There are no other options for writing a *portable*, ISO-conformant
time-sensitive program.

However, if you're using a POSIX variant, you can try gettimeofday()
or clock_gettime().  If you're using OSF, you can try getclock().
If you're using Win32, you can try GetSystemTime() or
GetSystemTimeAsFileTime().

-- David R. Tribble, dtribble@technologist.com --
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



