Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250785
  • 博文数量: 49
  • 博客积分: 1231
  • 博客等级: 少尉
  • 技术积分: 967
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-02 00:04
个人简介

-->软硬件结合的系统级开发工程师,带过团队,爱好心理学,哲学,艺术...偶像:达芬奇

文章存档

2014年(2)

2013年(4)

2012年(15)

2011年(28)

分类: C/C++

2011-06-26 19:46:45

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <system.h>
  4. #include <time.h>

  5. /*==================================
  6. 功能描述:打印出系统当前的实时时间
  7. 所用函数:ctime_print()
  8. 返回值: 有,返回当前系统时间
  9. ==================================*/

  10. main()
  11. {
  12.     time_t t=0;
  13.     const char *ctime_print(time_t value); /* 声明时间处理函数 */

  14.     printf("The currnet time is : %s\n",ctime_print(t));
  15.     sleep(5); /* 系统睡眠5秒 */
  16.     printf("The current time after 5 seconds is : %s\n",ctime_print(t));
  17.     getch();
  18. }

  19. const char *ctime_print(time_t value) /* 时间处理函数 */
  20. {
  21.     static char buf[32];
  22.     char *p;

  23.     time(&value);
  24.     strcpy(buf, ctime(&value));


  25.     if ((p = strchr(buf, '\n')) != NULL)
  26.         *p = '\0';

  27.     return buf;
  28. }
阅读(869) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~