使用stat函式獲取檔案基本資訊

2021-08-26 01:23:12 字數 398 閱讀 2787

函式原型:intstat(constchar*pathname,structstat*buf);

函式說明:

給stat

函式傳遞乙個

pathname

,stat

函式返回乙個與此命名檔案有關的資訊結構,該資訊結構中包含檔案的基本資訊。

#include #include #include #include #include #include using namespace std;

/**********************

*利用stat函式獲取某個檔案的相關資訊

** ********************/

int main()

程式執行結果:

c 獲取檔案資訊 stat函式的使用

stat函式用來獲取指定路徑的檔案或者資料夾的資訊。int stat const char path,struct stat buffer 引數 path 檔案或者資料夾的路徑 buffer 獲取的資訊儲存在記憶體中 返回值 正確 返回0 錯誤 返回 1,具體錯誤碼儲存在errno中 stat結構體...

c 獲取檔案資訊 stat函式的使用

stat函式用來獲取指定路徑的檔案或者資料夾的資訊。cpp view plain copy int stat const char path,struct stat buffer 引數 path 檔案或者資料夾的路徑 buffer 獲取的資訊儲存在記憶體中 返回值 正確 返回0 錯誤 返回 1,具體...

C語言stat 函式 獲取檔案狀態

相關函式 fstat,lstat,chmod,chown,readlink,utime 標頭檔案 include include 定義函式 int stat const char file name,struct stat buf 函式說明 stat 用來將引數file name 所指的檔案狀態,複...