对时间进行递增操作

来源:互联网 发布:穿越火线ak伤害数据 编辑:程序博客网 时间:2024/05/04 07:33
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>


  5. #define DAYSEC 3600*24

  6. int main(int argc, char*argv[])
  7. {
  8.         int off;
  9.         char * stime;
  10.         
  11.         time_t now_time;
  12.         time_t new_time;
  13.         
  14.         struct tm *pansctime;
  15.         
  16.         off = atoi(argv[1]);
  17.         printf("%d\n", off);
  18.         
  19.         now_time=time(NULL);
  20.         new_time=now_time+ off*DAYSEC;
  21.         pansctime = localtime(&new_time);
  22.         
  23.         stime = asctime(pansctime);
  24.         
  25.         printf("%s\n", stime);
  26.         return 0;
  27. }
0 0
原创粉丝点击