运行时候出错。。无法解析的外部符号。。不知道哪里错了,能不能帮我看看
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;
}