localtime question

Giorgos Keramidas keramida at ceid.upatras.gr
Tue Aug 10 10:13:01 PDT 2004


On 2004-08-10 18:45, Mipam <mipam at 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 at orion[20:11]/home/keramida$ ./a.out
        Mon Aug  9 20:11:30 2004

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

Bye



More information about the freebsd-questions mailing list