求a.replace()具体用法?

ppk_master ppk_master 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
菜鸟初学c++,对下面代码里面的a.replace()用法不慎明了,还望大侠赐教


//=====================================
// f0305.cpp
//=====================================
#include<iostream>
#include<algorithm>
using namespace std;
//-------------------------------------
int main(){
string a, s1 = "Hello ";
string s2 = "123";
a = s1; // copy
cout<<(a==s1 ? "" : " not")<<"equal\n"; // compare
cout<<(a+=s2)<<endl; // concatenate
reverse(a.begin(), a.end()); // reverse
cout<<a<<endl;
cout<<a.replace(0,9,9,'c')<<endl; // set cout<<(s1.find("ell")!= -1 ? "" : "not ")<<"found\n";// find string
cout<<(s1.find('c')!= -1 ? "": "not ")<<"found\n"; // find char
}//====================================



...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
ppk_master
C++ 语言 65,214 成员 250,514 内容