如题目所示,如何在vector<string>
中查找一个string
类型的字符串,标准库中的find()
对于vector<string>
类型不知道如何使用。 谢谢!
解决方案
vector<string> vstring;//传入迭代器auto index=std::find(vstring.begin(),vstring.end(),"string2find");if(index!=vstring.end()){ cout<<"找到了,是第"<<index<<"个"<<endl;}else{ cout<<"找不到"<<endl;}