delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/15/18:32:42

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: time() frequency
Date: 15 Nov 1999 13:57:49 -0800
Organization: InterWorld Communications
Lines: 29
Message-ID: <83ogcv8lk2.fsf@mercury.st.hmc.edu>
References: <FL8wAt DOT 2GG AT freenet DOT buffalo DOT edu>
NNTP-Posting-Host: mercury.st.hmc.edu
X-Trace: nntp1.interworld.net 942703135 62142 134.173.45.219 (15 Nov 1999 21:58:55 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 15 Nov 1999 21:58:55 GMT
X-Newsreader: Gnus v5.7/Emacs 20.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Kev <co273 AT freenet DOT buffalo DOT edu> writes:

> Hello Fellow DJGPPers!
> 
> I have a question concerning the DJGPP time() function.
> Can you tell me the frequency in which time() returns the time...
> Is it 1 second increments?  I'm trying to settle an argument with a
> co-worker, who argued that it is in Microsecond increments.

Yes, it's in seconds.  (Seconds since January 1, 1970 if I recall
correctly.)  This can be made pretty clear by doing

#include <stdio.h>
#include <time.h>

int main(void)
{
  for (;;)
    printf("Time: %ld\n", (long)time(NULL));
  return 0;
}

and noticing how often it changes.

Perhaps this should be added to the documentation.
-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019