函数原型
int stat(const char * file_name,struct stat *buf);
表头文件:
#include<unistd.h>
#include<sys/stat.h>
stat()用来将参数file_name所指的文件状态, 复制到参数buf所指的结构中。

const char*表示文件的路径,struct stat*buf 表示声明的结构体


stat,lstat,fstat函数来获取文件的状态,三个函数的功能将文件的状态复制到buffer的结构体当中去。

 

案例一:

Struct  stat buf;

int fd;

fd= ....

fstat(fd,&buf);

printf("test file size : %d ",buf.st_size)

C语言中stat函数的使用

 

相关文章:

  • 2022-12-23
  • 2021-06-27
  • 2022-01-01
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-10-20
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案