📄 stringreplace.cpp
字号:
//: C04:StringReplace.cpp
// From "Thinking in C++, 2nd Edition, Volume 2"
// by Bruce Eckel & Chuck Allison, (c) 2001 MindView, Inc.
// Available at www.BruceEckel.com.
// Simple find-and-replace in strings
//{L} ../TestSuite/Test
#include <string>
#include <iostream>
using namespace std;
int main() {
string s("A piece of text");
string tag("$tag$");
s.insert(8, tag + ' ');
cout << s << endl;
int start = s.find(tag);
cout << "start = " << start << endl;
cout << "size = " << tag.size() << endl;
s.replace(start, tag.size(), "hello there");
cout << s << endl;
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -