linux 使用lseek函数来获取文件大小
一、获取文件大小
/*测得文件大小*/
int filelen;
int fd;
int filelen= lseek(fd,0L,SEEK_END);
lseek(fd,0L,SEEK_SET);
printf("file size is %d
",filelen);
二、lseek使用说明
表头文件
#include<sys/types.h>
#include<unistd.h>
定义函数
off_t lseek(int filde,off_t offset ,int whence);
EEK_SET 将读写位置指向文件头后再增加offset个位移量。
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
copyright © 2008-2019 亿联网络 版权所有 备案号:粤ICP备14031511号-2