#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
string str1("Hello world");
string str2="Hi world";
cout<<str1.find("lol",0)<<endl;
cout<<str1.substr(3,5)<<endl;
cout<<str1.find_first_of("ord",0)<<endl;
cout<<str1.find_first_not_of("Hlleod",0)<<endl;
}
substr()函数是取字串,第一个参数为起始位置,第二个参数是长度。
find()函数是查找字串在str1中的位置,如果找不到就是string::npos,如果找到了就是在str1中的索引。
find_first_of()函数是str1中的每一个字母在第一个参数字符串中匹配,如果有,则返回第一个找到的str1中字母的索引,否则返回string::npos
find_first_not_of()函数是str1中的每一个字母在第一个参数字符串中匹配,如果没有,则返回第一个没找到的str1中字母的索引,否则返回string::npos
