以下程序,在编译时出错了,我用的是win-tc,我也不知道是哪里错了啊,我看书上就是这样写的
#include<stdio.h>
#define DELAY 128000
void update(struct my_time *t);
struct my_time{
int hours;
int minutes;
int seconds;
};
int main(void)
{
struct my_time systime;
systime.hours=0;
systime.minutes=0;
systime.seconds=0;
for(;;){
update(&systime);
display(&systime);
}
void update(struct my_time *t)/*就是这句出的错,我想可能是由于版本的原因吧,可是我不知道要怎么改,高手请指点一二,谢谢!*/
{
t->seconds++;
if(t->seconds==60){
t->seconds=0;
t->mintes++;
}
delay();
}
void delay(void)
{
long int t:
for(t=1;t<DELAY;++t);
}
void display(struct my_time *t)
{
printf("%02d:",t->hours);
printf("%02d:",t->minutes);
printf("%02d:",t->seconds);
----------------解决方案--------------------------------------------------------
能编译时 的错误提示也发上来看一下么?
----------------解决方案--------------------------------------------------------
[CODE]
#include<stdio.h>
#include <stdlib.h>
#define DELAY 128000
void update(struct my_time *t);
void display(struct my_time *t);
void delay(void);
struct my_time
{
int hours;
int minutes;
int seconds;
};
int main(void)
{
struct my_time systime;
systime.hours=0;
systime.minutes=0;
systime.seconds=0;
for(;;)
{
system ("cls");
update(&systime);
display(&systime);
}
return 0;
}
void update(struct my_time *t)
{
delay();
t->seconds++;
if(t->seconds==60)
{
t->seconds=0;
t->minutes++;
}
if(t->minutes==60)
{
t->minutes=0;
t->hours++;
}
if(t->hours==24)
t->hours=0;
}
void delay(void)
{
long int t;
for(t=1;t<DELAY;++t);
}
void display(struct my_time *t)
{
printf("%02d:",t->hours);
printf("%02d:",t->minutes);
printf("%02d",t->seconds);
}
[/CODE]
----------------解决方案--------------------------------------------------------