Date: Wed, 19 Sep 2001 16:04:00 +0300 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Gabriel Ambuehl <gabriel_ambuehl@buz.ch> Cc: questions@FreeBSD.ORG Subject: Re: ctime() and friends broken? Message-ID: <20010919160400.D66974@sunbay.com> In-Reply-To: <152166323750.20010919145655@buz.ch>; from gabriel_ambuehl@buz.ch on Wed, Sep 19, 2001 at 02:56:55PM %2B0200 References: <152166323750.20010919145655@buz.ch>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 19, 2001 at 02:56:55PM +0200, Gabriel Ambuehl wrote: > -----BEGIN PGP SIGNED MESSAGE----- > > Hello, > I'm trying to either use ctime() or strftime() to convert an int > containing the seconds since the epoch to a human readable string, > but > so far, the only thing I get are segfaults: > > #include <stdio.h> > #include <time.h> > > int main() > { > char timestr[40]; > ctime_r((time_t *) time(NULL), timestr); > printf("Time: %s\n", timestr); > return 0; > } > > Will result in a segfault and nothing else. The same happens when > I try to feed the int to gmtime() so I could use the resulting struct > tm as input to strftime(). What am I doing wrong (4.4RC)? > time(3) returns ``time_t'' not a ``time_t *''. Try that: time_t tm; tm = time(NULL); ctime_r(&tm, timestr); Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010919160400.D66974>