- #include <stdio.h>
- #include <string.h>
- #include <system.h>
- #include <time.h>
- /*==================================
- 功能描述:打印出系统当前的实时时间
- 所用函数:ctime_print()
- 返回值: 有,返回当前系统时间
- ==================================*/
- main()
- {
- time_t t=0;
- const char *ctime_print(time_t value); /* 声明时间处理函数 */
- printf("The currnet time is : %s\n",ctime_print(t));
- sleep(5); /* 系统睡眠5秒 */
- printf("The current time after 5 seconds is : %s\n",ctime_print(t));
- getch();
- }
- const char *ctime_print(time_t value) /* 时间处理函数 */
- {
- static char buf[32];
- char *p;
- time(&value);
- strcpy(buf, ctime(&value));
- if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0';
- return buf;
- }