strptime.3: Initialize tm structure in example program

Reported-by: Doug Manley <doug.manley@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2009-12-05 06:49:17 +01:00
parent 183d08ce41
commit 7e6b1afb45
1 changed files with 3 additions and 1 deletions

View File

@ -26,7 +26,7 @@
.\" Modified, aeb, 2001-08-31
.\" Modified, wharms 2001-11-12, remark on white space and example
.\"
.TH STRPTIME 3 2001-11-12 "GNU" "Linux Programmer's Manual"
.TH STRPTIME 3 2009-12-05 "GNU" "Linux Programmer's Manual"
.SH NAME
strptime \- convert a string representation of time to a time tm structure
.SH SYNOPSIS
@ -390,6 +390,7 @@ and
#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int
@ -398,6 +399,7 @@ main(void)
struct tm tm;
char buf[255];
memset(&tm, 0, sizeof(struct 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);