类型转换问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
hanyu
帖子: 49
注册时间: 2009-03-12 16:29

类型转换问题

#1

帖子 hanyu » 2009-05-18 22:19

#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
int main()
{ struct tm *tm_ptr ,timestruct;
time_t the_time;
char buf[256];
char *result;
(void) time(&the_time);
tm_ptr = localtime(&the_time);
strftime(buf,256,"%A %d %B, %I: %S %P", tm_ptr);
printf("strftime gives: %s\n",buf);
strcpy(buf,"Mon 26 July 1999,17:53 will do fine");
printf("calling strptime with: %s\n",buf);
tm_ptr = &timestruct;
result = strptime(buf, "%a %d %b %Y, %R",tm_ptr);
printf("strptime consumed up to : %s\n",result);
printf("strptime gives:\n");
printf("date: %02d/%02d/%02d\n",tm_ptr->tm_year,tm_ptr->tm_mon+1,tm_ptr->tm_mday);
printf("time: %02d:%02d\n",tm_ptr->tm_hour,tm_ptr->tm_min);
exit(0);
} 这是书上的例子,编译的时候出现警告说整型转换成指针未经过类型转换strftime.c:18: warning: assignment makes pointer from integer without a cast 我找不到这个程序哪里涉及到类型转换了呀,请求帮忙
回复