运行时候出错。。无法解析的外部符号。。不知道哪里错了,能不能帮我看看

LMX_fuck 2015-12-08 12:30:19
error LNK2019: 无法解析的外部符号 "struct Time __cdecl TimeDiff(struct Time,struct Time)" (?TimeDiff@@YA?AUTime@@U1@0@Z),该符号在函数 _main 中被引用

#include<stdio.h>
struct Time { //时间结构体
int hours;
int minutes;
int seconds;

};

void main()
{
int i,d;//d是返回的时间差
struct Time t1, t2;//定义两个时刻

int TimeDiff(struct Time t1, struct Time t2);

printf("请输入一个时刻(时 分 秒):");
scanf("%d%d%d", &t1.hours, &t1.minutes, &t1.seconds);
printf("请输入另一个时刻(时 分 秒):");
scanf("%d%d%d", &t2.hours, &t2.minutes, &t2.seconds);

d=TimeDiff(t1, t2);

printf("两时刻差为:%d秒",d);
}

int Timediff(struct Time t1, struct Time t2) {

int second1, second2;//秒
int t;

second1 = t1.hours * 3600 + t1.minutes * 60 + t1.seconds;//转换成秒
second2 = t2.hours * 3600 + t2.minutes * 60 + t2.seconds;

if (second1 > second2)t = second1 - second2;//计算
else t = second2 - second1;

return t;
}
...全文
80 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
linzertling 2015-12-08
  • 打赏
  • 举报
回复
如果函数在main函数之后定义,应该事先声明一下,你把TimeDiff声明在main之前试试
chehw_1 2015-12-08
  • 打赏
  • 举报
回复
注意字母大小写 int TimeDiff(struct Time t1, struct Time t2) { int second1, second2;//秒 int t;

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧