码迷,mamicode.com
首页 > 其他好文 > 详细

简单的时间显示

时间:2014-07-22 23:09:54      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   使用   

效果图:

mamicode.com,码迷

 

实现代码:

mamicode.com,码迷
/************************/
/*   简单的时间显示    */
/**********************/

#include <stdio.h>
#include <time.h>

/*使用sleep()函数用的头文件*/
#include <unistd.h> 

int main()
{
    int second=0, minute=0, hour=0, time_now=0;
    while (1)
    {
        time_now = time(0);
        second = time_now%60;
        minute = time_now%3600/60;
        hour = time_now%(60*60*24)/3600;
        hour = (hour +8)%24;
        printf("%2d : %02d : %02d\r",hour, minute, second);
        fflush(stdout);
        while ( sleep(1));

/*一直占用CUP*/
//while( time_now == time(0)); } return 0; }
mamicode.com,码迷

 

简单的时间显示,码迷,mamicode.com

简单的时间显示

标签:style   blog   http   java   color   使用   

原文地址:http://www.cnblogs.com/love--wenxing/p/3700335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!