c语言insert作用,C++string中的insert()插入函数详解
下面通过代码给大家介绍c++ string insert() 函数,具体内容如下:
basic_string& insert (size_type pos, ct basic_string& str);
在原串下标为pos的字符前插入字符串str
basic_string& insert (size_type pos, ct basic_
下面通过代码给大家介绍c++ string insert() 函数,具体内容如下:
basic_string& insert (size_type pos, ct basic_string& str);
在原串下标为pos的字符前插入字符串str
basic_string& insert (size_type pos, ct basic_string& str, size_type pos1, size_type n);
str从下标为pos1开始数的n个字符插在原串下标为pos的字符前
basic_string& insert (size_type pos, size_type n, char c);
在原串下标为pos的字符前插入n个字符c
代码:
#include
using namespace std;
int main()
{
string str="hello";
string s="Hahah";
str.insert(1,s);//在原串下标为1的字符e前插入字符串s
cout<
string str1="hello";
char c='w';
str1.insert(4,5,c);//在原串下标为4的字符o前插入5个字符c
cout<
string str2="hello";
string s2="weakhaha";
str2.insert(0,s2,1,);//将字符串s2从下标为1的e开始数个字符&#x
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2023-06-29 02:01:07
上一篇:linux系统镜像后缀及简单介绍
推荐阅读
留言与评论(共有 11 条评论) |
本站网友 城市大厦 | 10分钟前 发表 |
ct basic_string& str | |
本站网友 中国十大芯片企业 | 29分钟前 发表 |
5 | |
本站网友 视频网站排名 | 25分钟前 发表 |
5 | |
本站网友 天津期货 | 18分钟前 发表 |
s);//在原串下标为1的字符e前插入字符串s cout< string str1="hello"; char c='w'; str1.insert(4 | |
本站网友 道行天下 | 24分钟前 发表 |
size_type n | |
本站网友 丽人 | 27分钟前 发表 |
c);//在原串下标为4的字符o前插入5个字符c cout< string str2="hello"; string s2="weakhaha"; str2.insert(0 | |
本站网友 鲅鱼圈驾校 | 1分钟前 发表 |
s2 | |
本站网友 邓楠 | 28分钟前 发表 |
char c); 在原串下标为pos的字符前插入n个字符c 代码: #include using namespace std; int main() { string str="hello"; string s="Hahah"; str.insert(1 | |
本站网友 韩式三点定位双眼皮价格 | 29分钟前 发表 |
size_type n | |
本站网友 东风论坛 | 14分钟前 发表 |
size_type n); str从下标为pos1开始数的n个字符插在原串下标为pos的字符前 basic_string& insert (size_type pos |