主题:请各位高手帮忙看下这个程序哪出错了啊????
我想显示剩下的没有删除的作者名字和作品,以一个作者名字跟着一个作品的形式显示,可是下面的程序只显示作者名字,作品却显示不出来,请高手帮忙,在此谢过。
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main()
{
map<string,vector<string> > authors;
string author,works,searchItem;
do
{
cout<<"Enter author name (Ctrl+Z to end):"<<endl;
cin>>author;
if(!cin)
break;
vector<string> work;
cout<<"Enter suthor's works(ctrl+z to end):"<<endl;
while (cin>>works)
authors.insert (make_pair(author,work));
cin.clear ();
}while (cin);
cin.clear();
cout<<"Who is the author that you want erase:"<<endl;
cin>>searchItem;
map<string,vector<string> >::iterator iter=authors.find(searchItem);
if(iter==authors.end())
cout<<"Can't find this author"<<endl;
else
authors.erase(searchItem);
cout<<"author\t\twork:"<<endl;
for(iter=authors.begin();iter!=authors.end();++iter)
for(vector<string>::iterator vect=iter->second.begin(); vect!=iter->second.end();vect++)
cout<<iter->first<<"\t\t"<<*vect<<endl;
return 0;
}