谁帮我看看这个C程序哪里错了

来源:百度知道 编辑:UC知道 时间:2024/05/07 06:41:36
#include <stdio.h>
#include <dos.h>
void delay();
void update();
void display();
struct tm
{
int hours,minites,seconds;
};
main()
{
struct tm time;
time.hours=0;
time.minites=0;
time.seconds=0;
for(; ;)
{
update(&time);
display(&time);
}
}
void update(struct tm *t)
{
(*t).seconds++;
if((*t).seconds==60)
{
(*t).seconds=0;
(*t).minites++;
}
if((*t).minites==60)
{
(*t).minites=0;
(*t).hours++;
}
if((*t).hours==24) (*t).hours=0;
delay();
}
void display(struct tm *t)
{
printf("%d:",(*t).hours);
printf("%d:",(*t).minites);
printf("%d:\n",(*t).seconds);
}
void delay()
{
long int t;
for(t=1;t<128000;t++);
}
编译出现这样的错误
Error c:\COUT\TEST.C 36:Too few parameters in c

似乎tc已经有个函数叫delay了,需要带参数,你试试把你定义的delay函数改名看看。或者干脆用tc自带的delay延迟一定毫秒算了,就不用那个for循环了

ps: 你改成ffff没有通过是因为你没有替换所有的,我替换全部之后就通过了。好像三个地方要替换:上面声明的地方、调用的地方、函数定义的地方。

你想用那个DELAY函数来做什么呢

注意你的函数参数申明和定义不一样呵呵,下面测试通过,记得delay的128000再大些吧在我机器上太快了~^Q^
#include <stdio.h>
#include <dos.h>
struct tm
{
int hours,minites,seconds;
};
void delay();
void update(struct tm*);
void display(struct tm*);
main()
{
struct tm time;
time.hours=0;
time.minites=0;
time.seconds=0;
for(; ;)
{
update(&time);
display(&time);
}
}
void update(struct tm *t)
{
(*t).seconds++;
if((*t).seconds==60)
{
(*t).seconds=0;
(*t).minites++;
}
if((*t).minites==60)
{
(*t).minites=0;
(*t).hours++;
}
if((*t).hours==24) (*t).hours=0;
delay();
}
void display(struct tm *t)
{
printf("%d: