#include
#include
#include
int main()
{
std::string path = “D/ssss/reflection.hpp”;
//这情况下,默认下是std::ios_base::in读入 trun:在打开时舍弃流的内容
std::ifstream open_file(path, std::ios_base::ate | std::ios_base::binary);
std::size_t size = open_file.tellg();
open_file.seekg(std::ios_base::beg);
std::string buffer;
buffer.resize(size);
open_file.read((char*)buffer.c_str(), size);
open_file.close();
std::string write_path = “D:/reflection1.hpp”;
//app:每次写入,指针移动到末尾,也就是追加 out:写入,binary:二进流模式 trun:在打开时舍弃流的内容
std::ofstream write_file(write_path, std::ios_base::binary|std::ios_base::app);
for (int i =0;i<2;i++){
write_file.write(buffer.c_str(), buffer.size());
}
write_file.close();
//默认可读写模式
//std::fstream fs;
}