C语言编写一个时钟

[复制链接]
查看11 | 回复1 | 2011-4-20 22:41:52 | 显示全部楼层 |阅读模式
#include
struct time
{
int day;
int hour;
int minute;
int second;
}shijian;
void shizhong()
{
struct time *p;
p->second++;
if(p->second==60)
{
p->second=0;
p->minute++;
}
if(p->minute==60)
{
p->minute=0;
p->hour++;
}
if(p->hour==24)
{
p->hour=0;
p->day++;
}
}
void xianshi()
{
struct time *p;
printf("%2d:%2d:%2d:%2d\r",p->day,p->hour,p->minute,p->second);
}
void yanchi()
{
long i;
for(i=0;iday=p->hour=p->minute=p->second=0;
for(i=0;i<10000;i++)
{
shizhong();
xianshi();
yanchi();
}
}
不知怎么不能显示

回复

使用道具 举报

千问 | 2011-4-20 22:41:52 | 显示全部楼层
每个函数里的struct time *p;改成struct time *p=&shijian;话说时间库函数不好用么
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行