当前位置:网站首页>Erase method in string
Erase method in string
2022-07-02 08:00:00 【HBUcs2020】
1.
Put the starting position in the middle
Or starting position and number
#include<iostream>
#include<string>
using namespace std;
int main(){
string str = "hello c++! +++";
// From the position pos=10 Start deleting at , Until the end
// namely : " +++"
str.erase(10);
cout << '-' << str << '-' << endl;
// From the position pos=6 Start at , Delete 4 Characters
// namely : "c++!"
str.erase(6, 4);
cout << '-' << str << '-' << endl;
return 0;
}2.
iterator [ )
#include<iostream>
#include<string>
using namespace std;
int main(){
string str = "hello c++! +++";
// Delete "+++" One space before
str.erase(str.begin()+10);
cout << '-' << str << '-' << endl;
// Delete "+++"
str.erase(str.begin() + 10, str.end());
cout << '-' << str << '-' << endl;
return 0;
}3. Single character of iterator position
iterator erase(const_iterator position)
Delete a single character at the iterator position , And back to Next element The iterator
4.pop_back(): Delete the last element
5. Often with find Functions together
string longer("That's a funny hat.");
//size_type loc1 = longer.find("hat"); // There is
size_type loc1 = longer.find("hello"); // non-existent
if (loc1 == string::npos)
cout<< "not found" <<endl;边栏推荐
猜你喜欢

静态库和动态库

w10升级至W11系统,黑屏但鼠标与桌面快捷方式能用,如何解决

Sorting out dialectics of nature

【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》

The difference and understanding between generative model and discriminant model

【Programming】

Remplacer l'auto - attention par MLP

Look for we media materials from four aspects to ensure your creative inspiration

Proof and understanding of pointnet principle

Jetson nano installation tensorflow stepping pit record (scipy1.4.1)
随机推荐
最长等比子序列
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
open3d学习笔记五【RGBD融合】
Replace convolution with full connection layer -- repmlp
【TCDCN】《Facial landmark detection by deep multi-task learning》
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
简易打包工具的安装与使用
Execution of procedures
C # connect to MySQL database
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
Handwritten call, apply, bind
What if a new window always pops up when opening a folder on a laptop
On the confrontation samples and their generation methods in deep learning
[multimodal] clip model
Label propagation
w10升级至W11系统,黑屏但鼠标与桌面快捷方式能用,如何解决
SQLyog远程连接centos7系统下的MySQL数据库
用全连接层替代掉卷积 -- RepMLP
联邦学习下的数据逆向攻击 -- GradInversion
针对语义分割的真实世界的对抗样本攻击