编写一个程序,将一个子字符串s2插入到主字符串s1
来源:百度知道 编辑:UC知道 时间:2024/06/30 16:22:32
编写一个程序,将一个子字符串s2插入到主字符串s1
中,其起始插入位置为n.
中,其起始插入位置为n.
#include<string>
#include<iostream>
using namespace std;
string insert(string a,string b,int c)
{
string d = a.substr(0,c) + b + a.substr(c);
return d;
}
int main()
{
string a="hello, I am here.";
string b=" world";
cout<<insert(a,b,5)<<endl;
return 0;
}