现在的位置: 首页 > 综合 > 正文

C语言快速获取文件的大小

2013年08月09日 ⁄ 综合 ⁄ 共 199字 ⁄ 字号 评论关闭
C语言快速获取文件的大小的两种方法:
 
1.
 
long int size;
FILE *fp;
 
fp=fopen("file","rb");
fseek(fp,0,SEEK_END);
size=ftell(fp);
flcose(fp);
 
2.
 
int fd,size;
struct stat buf;
 
fd=open("file",O_RDONLY);
fstat(fd,&buf);
size=buf.st_size;

抱歉!评论已关闭.