【发布时间】:2009-10-26 18:24:14
【问题描述】:
我对 C 语言还是很陌生,正在尝试学习如何使用 strptime 来查看它是否适用于项目的一部分,但我什至无法让看起来像一个非常基本的示例正常工作......
int main()
{
struct tm *t;
t = (struct tm *) malloc(sizeof(struct tm));
memset(t, 0, sizeof(t));
if (strptime("12-2009", "%m-%Y", t) != NULL)
printf("month: %d year: %d\n",t->tm_mon, t->tm_year);
free(t);
return 0;
}
运行此程序给出:“月:11 年:109”
我在这里错过了什么??
【问题讨论】: