time 常用 文件

 #include <time.h>

struct tm *localtime(const time_t *timep);





struct tm {
               int tm_sec;         /* seconds */
               int tm_min;         /* minutes */
               int tm_hour;        /* hours */
               int tm_mday;        /* day of the month */
               int tm_mon;         /* month */
               int tm_year;        /* year */
               int tm_wday;        /* day of the week */
               int tm_yday;        /* day in the year */
               int tm_isdst;       /* daylight saving time */
         };
/ELAMPLE

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>

int main(void)
{
 struct stat sta;
 struct tm* time;
 
 int fid;
 if((fid=open("log",O_RDONLY | O_CREAT, 0664))==-1)
  perror("open");
 else
  printf("成功%d\n",fid);
 if(lstat("log",&sta)==-1)
  {
   perror("lstat");
   return -1;   
  }
 printf("%d\n",(int)sta.st_dev);
 printf("%d\n",(int)sta.st_uid);
 printf("%d\n",(int)sta.st_dev);
 printf("%d\n",(int)sta.st_atime);  
 time=localtime(&sta.st_atime);
 printf("%d:%d:%d\n",time->tm_year+1900,time->tm_mon+1,time->tm_sec);

 close(fid);
 
}





 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值