C++ primer 第四版 里面的第十章的单词转换,如何跑不起来啦

C++ primer 第四版 里面的第十章的单词转换,怎么跑不起来啦
/*
 * A program to transform works.
 * Takes two arguments:The first is name of the word transformation file
 * The second is name of the input to transform
 */
#include <iostream>
#include<string>
#include<stack>
#include<map>
#include<utility>
#include<stdexcept>
#include<fstream>
#include<sstream>
//#include<vector>
//#include<queue>
using std::cout;
using std::cin;
using std::endl;
using std::hex;
using std::dec;
using std::string;
using std::stack;
using std::map;
using std::pair;
using std::runtime_error;
using std::fstream;
using std::ifstream;
using std::istringstream;
//using std::stream

using std::getline;
// using namespace std;
   
// opens in binding it to the given file
  ifstream& open_file(ifstream &in,const string &file)
  {
in.close(); //close in case it was already open
in.clear(); //clear any existing errors
//if the open fails,the stream will be in an invalid state
in.open(file.c_str()); //open the file we were given
  return in; //condition state is good if open succeeded
  }


int main(int argc,char **argv)
{
//map to hold the word transformation pairs:
//key is the word to look for in the input;value is word to use in the output
map<string,string> trans_map;
string key ,value;
if(argc!=3)
throw runtime_error("wrong number of arguments");
//open transformation file and check that open succeeded
ifstream map_file;
if(!open_file(map_file,argv[1]))
throw runtime_error("no transformation file");
//read the transformation map and build the map
while (map_file>>key>>value)
trans_map.insert(make_pair(key,value));
//ok,now we're ready to do the transformation
//open the input file and check that the open succeeded
ifstream input;
if(!open_file(input,argv[2]))
throw runtime_error("no input file");
string line; //hold each line from the input
//read the text to transform it a line at a time
while(getline(input,line))
{
istringstream stream(line); // read the line a word at a line
string word;
bool firstword=true; //controls whether a space is printed
while(stream>>word)
{
//ok:the actual mapwork,this part is the heat of the program
map<string,string>::const_iterator map_it=
trans_map.find(word);
// if this word is in the transformation map
if(map_it!=trans_map.end())
//replace it by the transformation value in the map
word=map_it->second;
if(firstword)
firstword=false;
else
cout<<" "; // print space between words
cout<<word;
}
cout<<endl; //done with this line of input
  }



  return 0;
 }

------解决方案--------------------
throw runtime_error("wrong number of arguments");//这个事抛异常,在你机子上不能用,你把他换成打印比如printf("wrong number of arguments");
------解决方案--------------------
类似的throw 语句都改下
------解决方案--------------------
C/C++ code
if(argc!=3)
printf("wrong number of arguments");
if(!open_file(map_file,argv[1]))//你这些可以看出是要从命令行输入东西才行,所以这儿也要改下

------解决方案--------------------
C/C++ code