社区
C++ 语言
帖子详情
std::string 怎样实现类似VB的replace(str,str1,str2)
godidea
2003-09-12 10:54:45
rt
...全文
83
4
打赏
收藏
std::string 怎样实现类似VB的replace(str,str1,str2)
rt
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
pczhang
2003-09-13
打赏
举报
回复
好象还没有你想要的库函数,不过你可以用指针
sevencat
2003-09-13
打赏
举报
回复
楼主先去看看std::string的有关资料吧。
各种函数先瞧瞧吧。
WuYL7812
2003-09-13
打赏
举报
回复
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str = "abcdef";
string str2 = "cde";
//用"wxyz",替换"cde"
int pos = str.find(str2);
str.replace(pos,str2.size(),"wxyz", 4);
cout << str << endl;
return 0;
}
WuYL7812
2003-09-13
打赏
举报
回复
#include <algorithm>
string str = "abcdef";
replace(str.begin(), str.end(), 'a', 'b');
cout << str << endl;
std
::
str
ing
std
::vector
std
::map 源代码 结构
_
STD
_BEGIN #define _VECTOR_ORPHAN_RANGE (_ITERATOR_DEBUG_LEVEL == 2) // TEMPLATE CLASS _Vector_const_iterator template class _Vector_const_iterator : public _Iterator012, typename _Myvec::...
将一个字符串中指定位置进行反转
1.将
Str
ing
中指定位置进行反转 1.1问题阐述 举个例子:“abcdefg”字符串中指定2到5号位置进行反转,-------》"abfedcg" 1.2问题解决思路 如果题目阐述全部进行反转:则直接调用
Str
ing
Buffer类里面的reverse...
JSON for Modern C++
名-值对的集合- 在各种语言中,被
实现
为对象、记录、结构、字典、散列表、键列表、关联数组等; 值的有序列表- 在大多数语言中,被
实现
为数组、向量、列表、序列等。 JSON for Modern C++的设计目标就是: 直观的...
去除
Str
ing
双引号“ “
【代码】去除
Str
ing
双引号“
C++ builder之 字符串转换
//Ansi
str
ing
转char void __fastcall TForm1::Button1Click(TObject *Sender) { Ansi
Str
ing
Test = "哈哈"; char *chr = Test.c_
str
(); } //char转Ansi
str
ing
#include void __fastcall TForm1
C++ 语言
64,650
社区成员
250,478
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章