linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Kerrisk <mtk.manpages-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
To: Doug Manley <doug.manley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Error with EXAMPLE for strptime(3) (found in release 3.21)
Date: Sat, 5 Dec 2009 07:51:55 +0100	[thread overview]
Message-ID: <cfd18e0f0912042251g6d3c7ed7u5a1103d4c8ec0d57@mail.gmail.com> (raw)
In-Reply-To: <d539ea680911301317gbf313e0vf698b9ad1d136c0f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

           reply	other threads:[~2009-12-05  6:51 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <d539ea680911301317gbf313e0vf698b9ad1d136c0f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfd18e0f0912042251g6d3c7ed7u5a1103d4c8ec0d57@mail.gmail.com \
    --to=mtk.manpages-gm/ye1e23mwn+bqq9rbeug@public.gmane.org \
    --cc=doug.manley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).