如何把文件中的数据读入程序

 
  
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
int main()
{   
  string input_file_name;
  string output_file_name;
  cout<<"input the in_file_name: "<>input_file_name;
  cout<<"input the output_file_name: "<>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!"< is(f_in);
 istream_iterator eof; 
 vector text; 
 copy(is,eof,back_inserter(text)); 
  ostream_iterator os(f_out,""); 
 copy(text.begin(),text.end(),os);
 cout<<"the copy is over ! "<

你可能感兴趣的:(C++)