// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
// 字符串查找和替换
void test01()
{
string str1 = "abcdefg";
int pos = str1.find("df");
if (pos == -1)
{
cout << "cannot find string" << endl;
}
else {
cout << " pos = " << pos << endl;
}
//rfind
pos = str1.rfind("de");
cout << "pos = " << pos << endl;
}
// replace
void test02()
{
string str1 = "abcdefg";
str1.replace(1, 3, "1111");
cout << "str1 = " << str1 << endl;
}
int main()
{
test02();
}
192_string容器_字符串查找和替换
猜你喜欢
转载自blog.csdn.net/weixin_42990464/article/details/124538078
今日推荐
周排行