[LCP]time
Andrew Weaver
Andrew.Weaver at tecnomen.fi
Mon Jan 21 18:26:42 UTC 2002
What is in the time_t var now?
> -----Original Message-----
> From: Joachim Bauernberger [SMTP:bj at gmx.net]
> Sent: Friday, January 18, 2002 9:38 PM
> To: linuxCprogramming at lists.linux.org.au
> Subject: [LCP]time
>
> Hi,
> I am having a little problem with time. For some reason the code below
> will
> have the following output:
>
> [bjdev: C]$ ./time
> 12 41 10 23 11 35 1
> Mon Dec 23 10:41:12 1935
>
> The actual time however is:
> [bjdev: C]$ date
> Fre Jan 18 20:35:29 CET 2002
>
>
> Can somebody be so kind and tell me what I am doing wrong (maybe it's time
>
> for me to get some sleep .... :))
>
>
> Here is the code:
>
> #include <time.h>
> #include <stdio.h>
>
> int main( int argc, char **argv) {
>
> time_t now;
> struct tm *tt;
> char *c;
>
> tt = localtime(&now);
> //c = ctime(&now);
>
> fprintf(stdout,"%d %d %d %d %d %d %d\n",tt->tm_sec, tt->tm_min,
> tt->tm_hour, tt->tm_mday, tt->tm_mon, tt->tm_year, tt->tm_wday);
> //fprintf(stdout,"\n%s\n",c);
> c = asctime(tt);
> fprintf(stdout,"%s\n",c);
>
> return 0;
> }
>
> --
> You can get my public pgp key here:
> http://www.mxscan.com/pgp/joachim.asc
> PGP fingerprint:
> 25 96 E0 25 48 D9 8E 10 3C C0 48 E7 AF 5A E2 C6 A3 15 05 E6
>
> _______________________________________________
> This is the Linux C Programming List
> : http://lists.linux.org.au/listinfo/linuxcprogramming List
More information about the linuxCprogramming
mailing list