* Re: Error with EXAMPLE for strptime(3) (found in release 3.21)
[not found] ` <d539ea680911301317gbf313e0vf698b9ad1d136c0f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2009-12-05 6:51 ` Michael Kerrisk
0 siblings, 0 replies; only message in thread
From: Michael Kerrisk @ 2009-12-05 6:51 UTC (permalink / raw)
To: Doug Manley; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
Hello Doug,
On Mon, Nov 30, 2009 at 10:17 PM, Doug Manley <doug.manley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> The example, as per the first paragraph under NOTES, should initialize "tm"
> before working with it.
Thanks. Fixed for man-pages-3.24 (but I made the sizeof() into
"sizeof(struct tm)").
Cheers,
Michael
> EXAMPLE
> The following example demonstrates the use of strptime() and
> strftime(3).
>
> #define _XOPEN_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> +++ #include <string.h> // Needed for memset.
> #include <time.h>
>
> int
> main(void)
> {
> struct tm tm;
> char buf[255];
>
> +++ memset( &tm, 0, sizeof(tm) );
> strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
> strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);
> puts(buf);
> exit(EXIT_SUCCESS);
> }
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-12-05 6:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <d539ea680911301317gbf313e0vf698b9ad1d136c0f@mail.gmail.com>
[not found] ` <d539ea680911301317gbf313e0vf698b9ad1d136c0f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-12-05 6:51 ` Error with EXAMPLE for strptime(3) (found in release 3.21) Michael Kerrisk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).