371 of this book .
# include<iostream>
#include<map>
#include<string>
#include <ios>
#include <stdexcept>
using namespace std;
int main(int argc,char **argv)
{
string map_file,open_file;
map<string,string>trans_map;
string key,value;
if(argc != 3)
throw runtime_error ("wrong no. of argument")
ifstream map_file;
if(!open_file(map_file[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<<endl;
}
return 0;
}
I am getting an errors :
/home/ankit/wordtransfer.cc||In function ‘int main(int, char**)’:|
/home/ankit/wordtransfer.cc|14|error: expected `;' before ‘ifstream’|
/home/ankit/wordtransfer.cc|15|error: no match for call to ‘(std::string) (char&)’|
/home/ankit/wordtransfer.cc|17|error: no match for ‘operator>>’ in ‘map_file >> key’|
/home/ankit/wordtransfer.cc|19|error: aggregate ‘std::ifstream input’ has incomplete type and cannot be defined|
/home/ankit/wordtransfer.cc|25|error: variable ‘std::istringstream stream’ has initializer but incomplete type|
||=== Build finished: 5 errors, 0 warnings ===|
can anyone please help???