#include <fstream>
// 1. 打开图片文件
ifstream is("HhW7J.jpg", ifstream::in | ios::binary);
// 2. 计算图片长度
is.seekg(0, is.end);
int length = is.tellg();
cout << length <<endl;
is.seekg(0, is.beg);
// 3. 创建内存缓存区
char * buffer = new char[length];
// 4. 读取图片
is.read(buffer, length);
// 到此,图片已经成功的被读取到内存(buffer)中
if(buffer == NULL)
cout<< "buffer is null" << endl;