From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Kerrisk Subject: Re: Error with EXAMPLE for strptime(3) (found in release 3.21) Date: Sat, 5 Dec 2009 07:51:55 +0100 Message-ID: References: Reply-To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-man-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Doug Manley Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-man@vger.kernel.org Hello Doug, On Mon, Nov 30, 2009 at 10:17 PM, Doug Manley w= rote: > The example, as per the first paragraph under NOTES, should initializ= e "tm" > before working with it. Thanks. Fixed for man-pages-3.24 (but I made the sizeof() into "sizeof(struct tm)"). Cheers, Michael > EXAMPLE > =A0=A0=A0=A0=A0=A0 The following example demonstrates the use of strp= time() and > strftime(3). > > =A0=A0=A0=A0=A0=A0 #define _XOPEN_SOURCE > =A0=A0=A0=A0=A0=A0 #include > =A0=A0=A0=A0=A0=A0 #include > +++=A0=A0=A0=A0=A0=A0 #include // Needed for memset. > =A0=A0=A0=A0=A0=A0 #include > > =A0=A0=A0=A0=A0=A0 int > =A0=A0=A0=A0=A0=A0 main(void) > =A0=A0=A0=A0=A0=A0 { > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 struct tm tm; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 char buf[255]; > > +++ =A0=A0=A0=A0=A0=A0=A0=A0=A0 memset( &tm, 0, sizeof(tm) ); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 strptime("2001-11-12 18:31:01", "%Y-%m= -%d %H:%M:%S", &tm); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 strftime(buf, sizeof(buf), "%d %b %Y %= H:%M", &tm); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 puts(buf); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 exit(EXIT_SUCCESS); > =A0=A0=A0=A0=A0=A0 } > --=20 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