DumpBinary
stdafx.h
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
main.cpp
#include "stdafx.h"
int main(int argc, char *argv[])
{
#if 0
if (argc != 3)
{
return 0;
}
std::fstream fs(argv[1], std::ios::binary | std::ios::trunc | std::ios::in | std::ios::out);
#endif
std::fstream in("D:\\axhelper.exe", std::ios::binary | std::ios::in);
if (!in.is_open())return 1;
//至文件尾获取文件大小
in.seekg(0,std::ios::end);
std::streamoff inSize = in.tellg();
std::cout << "文件大小:" <<inSize << std::endl;
//至文件头
in.seekg(0, std::ios::beg);
//分配内存
char *buff = (char*)std::calloc((size_t)inSize, sizeof(char));
//释放内存
std::free(buff);
in.close();
getchar();
//fs.read()
return 0;
}
转载请注明出处并保持作品的完整性,谢谢