Mail Archives: djgpp/2001/07/31/06:00:08
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: question about getkey() , time() and how to pick a char from the screen
|
Date: | 31 Jul 2001 09:55:21 GMT
|
Organization: | Aachen University of Technology (RWTH)
|
Lines: | 26
|
Message-ID: | <9k5va9$r56$1@nets3.rz.RWTH-Aachen.DE>
|
References: | <01c11959$9c6f2d00$108784d5 AT feta>
|
NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de
|
X-Trace: | nets3.rz.RWTH-Aachen.DE 996573321 27814 137.226.32.75 (31 Jul 2001 09:55:21 GMT)
|
X-Complaints-To: | abuse AT rwth-aachen DOT de
|
NNTP-Posting-Date: | 31 Jul 2001 09:55:21 GMT
|
Originator: | broeker@
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Gwen <mb11363 AT chello DOT be> wrote:
> How to use correctly time() ? I tried to make a countdown of 3 sec :
> float quantum=3;
> time_t t=time(NULL);
> while (time(NULL) - t < quantum) {
According to the scriptures, you should never do any arithmetics on
time_t yourself. The language standard doesn't let you know what a
time_t variable really contains. Instead, you should use the
'difftime()' function, which exists exactly for that purpose.
> it works, in fact it works till quantum=1, below (like quantum=0.1)
> it acts as quantum=1, why?
No particular reason. It just does.
> maybe the second is the unit of the function time() ?
In DJGPP and all POSIX-like systems: yes. But it may be better not to
rely on that too much.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -