直接用tm 结构 方便。
程序重写如下:
#include
#include
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main ()
{
time_t rt;
struct tm *t;
long int i;
for (i=0;i<3600;i++)
{
time ( &rt );
t = localtime ( &rt );
system("cls");printf("\n\n\n\n\n\n\n\n\t");
printf ( "Year: %d ", t->tm_year+1900 );
printf ( "Month: %d ", t->tm_mon +1 );
printf ( "day: %d ", t->tm_mday);
printf ( "hour: %d ", t->tm_hour);
printf ( "minute: %d ", t->tm_min);
printf ( "second: %d\n", t->tm_sec);
wait (1);
}
return 0;
}
你可以把英文年月日时分秒改中文字。
for 循环改无限循环。
本程序不修改系统时间。