獲取文件大小

#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   )   );   
        }   
  }   
發佈了63 篇原創文章 · 獲贊 2 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章