192_string容器_字符串查找和替换

网友投稿 484 2022-11-23

192_string容器_字符串查找和替换

192_string容器_字符串查找和替换

// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。//#include#include#include#includeusing 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; }// replacevoid test02(){ string str1 = "abcdefg"; str1.replace(1, 3, "1111"); cout << "str1 = " << str1 << endl;}int main(){ test02();}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:191_string容器_字符串拼接
下一篇:195_字符串插入和删除
相关文章

 发表评论

暂时没有评论,来抢沙发吧~