获取文件大小

来源:互联网 发布:淘宝卖什么比较好? 编辑:程序博客网 时间:2024/05/16 17:03
#include   <time.h>   
  #include   <sys/types.h>   
  #include   <sys/stat.h>   
  #include   <stdio.h>   
    
  void   main(   void   )   
  {   
        struct   stat   buf;   
        int   result;   
        char   buffer[]   =   "A   line   to   output";   
    
        result   =   stat(   "stat.c",   &buf   );   
    
        if(   result   !=   0   )   
              perror(   "Problem   getting   information"   );   
        else   
        {   
              printf(   "File   size           :   %ld\n",   buf.st_size   );   
              printf(   "Drive                   :   %c:\n",   buf.st_dev   +   'A'   );   
              printf(   "Time   modified   :   %s",   ctime(   &buf.st_mtime   )   );   
        }   
  }   
0 0
原创粉丝点击