C++-IO操作之从文件读取输出到标准输出

#include <fstream>

int main()
{
    cout << "filename: ";
    string file_name;

    cin>>file_name;

    //打开文件copy.out用于用户输入
  ifstream inFile( filename.c_str() );

  if ( !inFile ) {
      cerr << "unable to open input file: "
             << file_name << " -- bailing out!\n";

  char ch;
  while ( inFile.get(ch))
      cout.put ( ch );
  }
 

 

posted on 2013-03-27 23:06  醉清风JM  阅读(224)  评论(0)    收藏  举报

导航