C++ 获取文件大小(字节)

#include<iostream>
#include<fstream>
using namespace std;
void main()
{
	FILE *pFile;
	char *file;
	file="E:/图片/Saved Pictures/7.jpg";
	pFile=fopen(file,"rb");  //获取已打开文件的指针
	fseek(pFile,0,SEEK_END);  //先用fseek将文件指针移到文件末尾
	int n=ftell(pFile);    //再用ftell获取文件内指针当前的文件位置。
	//这个位置就是文件大小。
	cout<<n<<endl;
}

原文地址:https://www.cnblogs.com/zztong/p/6695198.html