Chinaunix首页 | 论坛 | 博客
  • 博客访问: 523195
  • 博文数量: 86
  • 博客积分: 1076
  • 博客等级: 准尉
  • 技术积分: 1018
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-02 19:15
文章分类

全部博文(86)

文章存档

2013年(15)

2012年(69)

2011年(2)

分类: LINUX

2012-04-01 14:32:59


点击(此处)折叠或打开

  1. 头文件:#include <time.h>

  2. 原型:time_t time(time_t *t);

  3. 描述:time()返回自1970-01-01 00:00:00 +0000 (UTC)到现在的秒数。

  4.         如果t不是NULL,返回值也存储到t指向的内存中。

  5. 返回值:成功时,返回自Epoch到现在的秒数。错误时,返回((time_t)-1),且设置errno为相应的值。

  6. 错误:EFAULT t指向了可访问的地址之外的地址。

  7. 例子:

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

  10. int main(void)
  11. {
  12.         time_t t;
  13.         time_t ptr;

  14.         t = time(&ptr);

  15.         printf("t:%ld, ptr:%ld\n", t, ptr);

  16.         return 0;
  17. }

  18. 测试:./time
  19. t:1324133685, ptr:1324133685

阅读(623) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~