当前位置: 代码迷 >> 综合 >> replace()用法
  详细解决方案

replace()用法

热度:95   发布时间:2024-03-06 20:07:32.0
#include<iostream>
#include<string>
using namespace std;
int main()
{string str = "abcdef";str.replace(0,3,"XXX");cout << str << endl;       //输出: XXXdefstr.replace(0, 3, 3, 'Y');cout << str << endl;	   //输出: YYYdefstring s = "2020";str.replace(0, 3, s, 0, 3);cout << str << endl;       //输出: 202defreturn 0;
}

 

  相关解决方案