stat
by
stat 函数
获取文件属性信息(大小、权限、修改时间等)
函数原型:
int stat(const char *pathname, struct stat *buf)
参数:
-
pathname:要查询的文件路径
-
buf:输出参数,指向 struct stat 类型结构体
返回值:
-
成功返回 0
-
失败返回 -1
struct stat st;
stat("file.txt", &st);
printf("Size: %ld bytes\n", st.st_size);