C语言问题 高手请进啊!

来源:百度知道 编辑:UC知道 时间:2024/05/14 12:50:22
我要编写一个比较发车时间与当前系统时间的程序
如下
错在哪里啊
其中tur[i].star代表是发车时间

int compare(int i, int a)/*//比较发车时间与当前系统时间*/
{ char tmpbuf[10];
char temp[10],*p=temp;
p= _strtime(tmpbuf);
a=strcmp(temp,tur[i].star);

return a;
}
那如果是这样呢
这是我自己修改后的
int compare(int i)
{
int a;
char tmpbuf[10];
char temp[10];
strcpy(temp,_strtime(tmpbuf));
a=strcmp(temp,tur[i].star);
return a;
}

你修改过后的好多了,你这个函数只能进行字符串比较,也即是说你的日期其实都是字符串,只能比较两个字符串的时间是否相等.

还有,你认为你调用strcpy实在在多此一举,我觉得你这样会更好些
int compare(int i)
{
int a;
char tmpbuf[9];
_strtime(tmpbuf);
a=strcmp(tmpbuf,tur[i].star);
return a;
}

还有,我对你的这个函数有点疑问是,你调用strtime得到的时间是系统的当前时间,比如:19:22:31 ,你与tur中的时间进行比较,能比较成功功吗?系统的当前时间是随时都在变化的,不知道你这样进行比较的意义.

int compare(int i, int a)/*//比较发车时间与当前系统时间*/
{ char tmpbuf[10];
char temp[10],*p=temp;
p= _strtime(tmpbuf);
a=strcmp(temp,tur[i].star);

return a;
}

云 什么东西啊