Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Aug 2004 20:12:56 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Mipam <mipam@ibb.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: localtime question
Message-ID:  <20040810171256.GA26475@orion.daedalusnetworks.priv>
In-Reply-To: <Pine.BSO.4.56.0408101842210.21307@ux11.ltcm.net>
References:  <Pine.BSO.4.56.0408101646230.26666@ux11.ltcm.net> <20040810162612.GC25389@orion.daedalusnetworks.priv> <Pine.BSO.4.56.0408101842210.21307@ux11.ltcm.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-08-10 18:45, Mipam <mipam@ibb.net> wrote:
> #include <stdio.h>
> #include <sys/time.h>
>
> int main(void)
> {
> struct timeval tv;
> struct timeval tv_current;
> if (gettimeofday(&tv_current, NULL) == -1)
>    err(1, "Could not get local time of day");
> tv.tv_sec = tv_current.tv_sec-86400;
> printf("%s\n", ctime(&tv.tv_sec));
> return 0;
> }

Hmmm, now that I noticed.  You don't need to add a trailing '\n' to the
string of ctime().  It already has one:

        keramida@orion[20:11]/home/keramida$ ./a.out
        Mon Aug  9 20:11:30 2004

        keramida@orion[20:11]/home/keramida$

Bye



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040810171256.GA26475>