#include<iostream>
using namespace std;
// # 1、z字符串的查找
void test01(){
string str1 = "abcdfggdf";
// 被查对象.find("查询内容",索引起点);
// 从左往右查找,返回 第一个 与查询内容相同的索引
int pos = str1.find("df",3) ; // 找不到的情况会返回值为:-1
cout << "pos = " << pos <<endl;// 3
// rfind 和 find区别
// rfind从左往右查找 find从左往右查找,仅此而已
pos = str1.rfind("df");
cout << "pos = " << pos <<endl; // 7
}
// # 2、替换
void test02(){
string str1 ="abcdefg";
str1.replace(1,3,"1111");
// 从1号位置起3个字符,替换为 四个"1111"
cout << "str1 = "<< str1 << endl;
}
int main(){
test01();
test02();
return 0;
}