find();
a串中,b串完全匹配才返回位置,不然返回string::npos.
#include <string >
#include <iostream>
using namespace std;
int main()
{
string a="123456789";
cout<<a.find("10");
cout<<endl;
cout<<string::npos;
return 0;
}
还有四个函数:
根据字面意思可使用
find_first_of()
find_first_not_of()
find_last_of()
find_last_not_of()
本文介绍了C++标准库中字符串类的find()方法及其变种的使用方法,这些方法包括find_first_of(), find_first_not_of(), find_last_of()和find_last_not_of(),通过实例演示了如何在字符串中进行精确匹配。

被折叠的 条评论
为什么被折叠?



