C语言(stat函数获取文件大小)

/*
函数原型:int stat(const char * file_name,struct stat *buf);
            stat()用来将参数file_name所指的文件状态, 复制到参数buf所指的结构中
            const char:表示文件路径
            struct stat*buf: 表示声明的结构体
 1 struct stat {
 2     dev_t st_dev; //device 文件的设备编号
 3     ino_t st_ino; //inode 文件的i-node
 4     mode_t st_mode; //protection 文件的类型和存取的权限
 5     nlink_t st_nlink; //number of hard links 连到该文件的硬连接数目, 刚建立的文件值为1.
 6     uid_t st_uid; //user ID of owner 文件所有者的用户识别码 
 7     gid_t st_gid; //group ID of owner 文件所有者的组识别码 
 8     dev_t st_rdev; //device type 若此文件为装置设备文件, 则为其设备编号 
 9     off_t st_size; //total size, in bytes 文件大小, 以字节计算 
10     unsigned long st_blksize; //blocksize for filesystem I/O 文件系统的I/O 缓冲区大小. 
11     u nsigned long st_blocks; //number of blocks allocated 占用文件区块的个数, 每一区块大小为512 个字节. 
12     time_t st_atime; //time of lastaccess 文件最近一次被存取或被执行的时间, 一般只有在用mknod、 utime、read、write 与tructate 时改变.
13     time_t st_mtime; //time of last modification 文件最后

你可能感兴趣的:(C语言文件操作,c语言)