Re: Error with EXAMPLE for strptime(3) (found in release 3.21)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Doug,

On Mon, Nov 30, 2009 at 10:17 PM, Doug Manley <doug.manley@xxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux