程序运行出问题,帮忙解决下啊
我把书上的程序打了一遍想运行下看有什么结果,编译链接时都没有错误就是在运行时,系统“嘣”的响了一声,弹了个框,debug error:Debug Error!Program: C:.......hahaha.exe
R6010
-abort() has been called
Press Retry to debug the application...
程序肯定没有问题我照书上抄的,我也没有打错,不过我还是把程序贴出来吧,感觉应该和程序没有关系
#include<iostream>
#include<fstream>
#include<sstream>
#include<list>
#include<string>
#include<vector>
#include<utility>
#include<map>
using namespace std;
int main(int argc,char**argv)
{
map<string,string>trans_map;
string key,value;
if(argc!=3)
throw runtime_error("wrong number of arguments");
ifstream map_file;
ifstream& open_file(ifstream& in,const string &file);
if(!open_file(map_file,argv[1]))
{
throw runtime_error("no transformation file");
}
while(map_file>>key>>value)
trans_map.insert(make_pair(key,value));
ifstream input;
if(!open_file(input,argv[2]))
throw runtime_error("no input file");
string line;
while(getline(input,line))
{
istringstream stream(line);
string word;
bool firstword=true;
while(stream>>word)
{
map<string,string>::const_iterator map_it=trans_map.find(word);
if(map_it!=trans_map.end())
word=map_it->second;
if(firstword)
firstword=false;
else
cout<<" ";
cout<<word;
}
cout<<endl;
}
return 0;
}
ifstream& open_file(ifstream& in,const string &file)
{
in.close();
in.clear();
in.open(file.c_str());
return in;
}