#include <iostream> #include <string> #include <algorithm> #include <functional> #include <iterator> #include <vector> #include <fstream> using namespace std; int main() {
string input_file_name; string output_file_name; cout<<"input the in_file_name: "<<endl; cin>>input_file_name; cout<<"input the output_file_name: "<<endl; cin>>output_file_name; ifstream f_in(input_file_name.c_str()); ofstream f_out(output_file_name.c_str()); if(!f_in || !f_out)
{ cout<<"can't open the file!"<<endl; exit(0); } istream_iterator<char> is(f_in); istream_iterator<char> eof; vector<char> text; copy(is,eof,back_inserter(text)); ostream_iterator<char> os(f_out,""); copy(text.begin(),text.end(),os); cout<<"the copy is over ! "<<endl; return 0; }
如何把文件中的数据读入程序
最新推荐文章于 2021-12-10 00:01:16 发布