- 论坛徽章:
- 5
|
rt,man手册上的原型:char *strptime(const char *s, const char *format, struct tm *tm),但下面的代码编译时总是有警告,到底是什么原因引起的?
./test2.c: In function ‘main’:
./test2.c:16: warning: assignment makes pointer from integer without a cast
#include<stdio.h>
//#define _XOPEN_SOURCE
#include<time.h>
int main(void)
{
char buf[128] = {0};
char * result = NULL;
//int result = -1;
struct tm tm_struct;
strcpy(buf, "Thu 26 July 2007 11:11");
result = strptime(buf, "%a %d %b %Y %R", &tm_struct);
printf("%d-%d-%d %d:%d:%d\n", tm_struct.tm_year, tm_struct.tm_mon + 1, tm_struct.tm_mday, tm_struct.tm_hour, tm_struct.tm_min, tm_struct.tm_sec);
printf("%s\n", result);
return 0;
}
glibc版本是2.12, gcc 版本是4.4.7 |
|