From owner-freebsd-questions Fri Oct 27 12:10:53 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id MAA13317 for questions-outgoing; Fri, 27 Oct 1995 12:10:53 -0700 Received: from terra.aros.net (angio@terra.aros.net [205.164.111.2]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id MAA13310 for ; Fri, 27 Oct 1995 12:10:50 -0700 Received: (from angio@localhost) by terra.aros.net (8.6.12/8.6.12) id NAA14179; Fri, 27 Oct 1995 13:10:41 -0600 From: Dave Andersen Message-Id: <199510271910.NAA14179@terra.aros.net> Subject: Re: Help -- Stupid "C" question. To: wollman@lcs.mit.edu (Garrett A. Wollman) Date: Fri, 27 Oct 1995 13:10:40 -0600 (MDT) Cc: freebsd-questions@freebsd.org In-Reply-To: <9510271522.AA22958@halloran-eldar.lcs.mit.edu> from "Garrett A. Wollman" at Oct 27, 95 11:22:05 am X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 1481 Sender: owner-questions@freebsd.org Precedence: bulk Lo and behold, Garrett A. Wollman once said: > > Hey, it's portable programming time! > > Actually, let's be slightly more accurate here. > > time(3) takes as its only argument a pointer to type `time_t'. If > that pointer is not null (NB: not `not NULL'), then it fills in that > location with the current time. In any case, it also returns a value > of type `time_t'. (Old systems spelled `time_t' l-o-n-g, but you > should use `time_t' and define it yourself if the system doesn't. > FreeBSD always has.) Depending on your preferred style of > programming, you might want to write either: > > time_t thetime; > time(&thetime); > or > time_t thetime; > thetime = time((time_t *)0); > > Note that the `(time_t *)' case is important for portable programs, > unless you can guarantee that a complete prototype of the `time' > function is in scope. (I consider it to be good style anyway.) The You are, of course, entirely correct here. I seem to have been bitten by the laziness bug. :) My use of the 'long' was somewhat egregious, however; it's the kind of thing that makes code break wildly after a long int isn't long enough to store the time since time began. -Dave Andersen -- angio@aros.net Complete virtual hosting and business-oriented system administration Internet services. (WWW, FTP, email) http://www.aros.net/ http://www.aros.net/about/virtual/ "She totally confused all the passing piranhas"