#include <map>
#include <string>
#include <iostream>
#include <fstream>
typedef std::multimap<std::string, std::string> dictionary;
typedef std::pair<std::string, std::string> dict_pair;
int main()
{
std::ifstream in("info.txt");
in.exceptions(std::ifstream::eofbit);
dictionary dict;
// parse file
try{
bool nextWord = true;
std::string word;
while(!in.eof())
{
if(nextWord)
{
std::getline(in, word);
nextWord = false;
}
std::string trans;
std::getline(in, trans);
if(trans.empty())
{
nextWord = true;
continue;
}
dict.insert(dict_pair(word, trans));
}
}catch(std::ifstream::failure exc){
//TODO: May be illegal file format
}
dictionary::iterator itr = dict.begin();
for(; itr != dict.end(); itr++)
std::cout << itr->first << " => " << itr->second << std::endl;
in.close();
}