专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>c语言教程>

time(system系统库函数)

百度收藏 QQ搜藏

 原型:extern int time(struct tm *pTime);
             
  用法:#include <system.h>
 
  功能:取得系统时间
 
  说明:结构tm在system.h中定义
        struct tm
        {
          int  hsec;    /* Half Seconds.  [0-119] */
          int  sec;     /* Seconds        [0-59]  */
          int  min;     /* Minutes        [0-59]  */
          int  hour;    /* Hours          [0-23]  */
          int  day;     /* Day            [0-30]  */
          int  wday;    /* Day of Week    [0-6]   */
          int  mon;     /* Month          [0-11]  */
          int  year;    /* Year - 1881            */
        };      
    
  举例:

      // timec
     
      #include <system.h>
      #define CPR 14

      main()
      {
        struct tm t1,t2;
        char wday[][3]={"日","一","二","三","四","五","六"};
       
        clrscr();
        textmode(0xE0);
        time(&t2);
        while(!kbhit())
        {
          noidle();
          time(&t1);
          if(t1.hsec==t2.hsec) continue;
          t2.hsec=t1.hsec;
          move(1,1);
          printf("%d年%2d月%2d日",t1.year+1881,t1.mon+1,t1.day+1);
          move(2,(CPR-8)/2+1);
          printf("%d:%d%d:%d%d",t1.hour,t1.min/10,t1.min%10,t1.sec/10,t1.sec%10);
          move(3,2);
          printf("今天是星期%s",wday[t1.wday]);
        }
       
        return 0;
      }

上一篇:rectangle(system系统库函数) 下一篇:write_chi_font(system系统库函数)

power by soyo123 2007-2008