C++ string和map容器实现简单的英文翻译

C++ string和map容器实现简单的英文翻译_第1张图片

int main(int argc, const char *argv[])
{
    ifstream ifl;
    ifl.close();
    ifl.clear();

    string mapfilename("map.txt");
    string transformname("transform.txt");

    ifl.open(mapfilename.c_str());
    
    string key,value;
    map maptransform;
    while(ifl>>key>>value)
    {
        maptransform.insert(make_pair(key,value));     
    }
    ifl.close(); 
    ifl.clear();
    
    ostream::fmtflags oldflags=cout.flags(); 
    
    map::iterator iter=maptransform.begin();
    
    cout<<"---------------------------------------"<first;
        cout<second;
        cout<first);
            if(pos!=string::npos)
                subtext.replace(pos,iter->first.size(),iter->second);
        }
        cout<>word)
        {
            map::const_iterator iter=
                maptransform.find(word);
            if(iter!=maptransform.end())
                word=iter->second;
            cout<<(firstword?(firstword=false,""):" ")<


你可能感兴趣的:(C++,stl)