【发布时间】:2011-10-10 11:15:25
【问题描述】:
这是我的程序 time_play.c:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int
main (void)
{
char *time_str = "2011-07-20 17:30:18";
time_t time_tm = getdate(time_str);
printf("str: %s and time: %s \n", time_str, ctime(&time_tm));
return 0;
}
它的输出:
$ gcc -o time_play time_play.c
$ ./time_play
str: 2011-07-20 17:30:18 and time: Wed Dec 31 16:00:00 1969
可以看出时间正在取值NULL。为什么会这样?
【问题讨论】:
-
你在哪个平台上?我对
getdate的原型是struct tm *getdate(const char *string);。