to myself 的分类学习日志

做自己想做的事
posts - 232, comments - 6, trackbacks - 0, articles - 0

CTime

Posted on 2012-05-02 18:57 kongkongzi 阅读(121) 评论(0)  编辑 收藏 引用 所属分类: c++ programming
验证time_t值是否正确
 1/* ctime example */
 2#include <stdio.h>
 3#include <time.h>
 4#include <stdlib.h>
 5
 6
 7int main (int argc, char* argv[])
 8{
 9  if (argc != 2)
10  {
11      printf("Usage: %s sec\n", argv[0]);
12      return -1;
13  }

14
15
16  time_t t = (time_t)atoi(argv[1]);
17  printf ( "The input's local time is: %s\n", ctime(&t) );
18
19  // time_t rawtime;
20  //struct tm * ptm;
21
22  //time ( &rawtime );
23  //ptm = gmtime ( &rawtime );
24  
25  return 0;
26}



只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理