filelength函数用于获取文件的长度,但是最大只能获取2g的文件大小,因为返回值类型long使用4个字节大小来表示,最大为2的31次方也就是2G的大小。
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <io.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string strpath = "D:\\Dtest5\\Readjpg\\1.jpg";
FILE*file=fopen(strpath.c_str(),"r");
long intiSize=filelength(fileno(file)); fclose(file);
cout<<intiSize<<endl;
return 0;
}