代码
#include <cstdio>
#include <string>
using namespace std;
int main() {
string str = "howareyou";
//int pos = str.find("are");
int pos = str.find("was");
// 判断一下are有没有在str中出现过
if (pos != string::npos){
// 有匹配
printf("Found, pos = %d\n", pos);
} else{
// 没有匹配项
printf("Not found\n");
}
return 0;
}