clock t;
t.hour=get_hour();
t.minuts=get_minuts();
t.seconds=get_seconds();
把我发的第一段代码保存起来,以后可以直接调用里面的函数
追问第二段是这样写吗?
追答你完全照抄啊,,哈哈
前面加个 struct 试试
追问还没有学时间函数
t未知啊?
追答你的主函数里面没有clock那个结构吧,这个结构要写进去才行啊。。。
strucr clock{
int ....
省略。。。
}
main(){}
这样?
追答唉,不是不是
等我回去以后,写个完整的给你好了
追问把第一段放进
struct clock{
…
};里吗?
你发的照片的那个时钟结构,第一个照抄
追问5 18 F:\C++(download)\临时编程文件\2.c [Error] expected ':', ',', ';', '}' or '__attribute__' before '{' token
int get_year(){
这句怎么错了?
追答唉。我发给你的第一段代码你保存为头文件,然后在你的主程序里面包含它
追问怎么保存为头文件?没学
追答晕,,,你上几年级啊?
追问大一
追答#include
#include
struct clock {
int hour;
int minuts;
int seconds;};
int main(){
struct clock t;
time_t ti;
struct tm *l;
ti=time(&ti);
l = localtime(&ti);
t.hour=l->tm_hour;
t.minuts=l->tm_min;
t.seconds=l->tm_sec;
printf("time is %d:%d:%d",t.hour,t.minuts,t.seconds);
return 0;
}
好了,这个我测试过了。。。绝对通过。。。
我想要的是时间会变化的程序……
追答时间会变化?什么意思,不停的跳动的秒?
切,贪婪了。。。
追问不会动的不叫时钟了……
编出来了,谢谢了
不发不采纳
追答现在没有到中午吧,邮箱