当前位置:网站首页>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;边栏推荐
- Execution of procedures
- 【Batch】learning notes
- Open3D学习笔记一【初窥门径,文件读取】
- open3d学习笔记三【采样与体素化】
- 【Random Erasing】《Random Erasing Data Augmentation》
- Real world anti sample attack against semantic segmentation
- Network metering - transport layer
- One book 1078: sum of fractional sequences
- The internal network of the server can be accessed, but the external network cannot be accessed
- 【学习笔记】Matlab自编高斯平滑器+Sobel算子求导
猜你喜欢

Sequence problem for tqdm and print

A brief analysis of graph pooling

Specification for package drawing

【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》

Graph Pooling 简析

【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》

Real world anti sample attack against semantic segmentation

Pointnet understanding (step 4 of pointnet Implementation)
![[mixup] mixup: Beyond Imperial Risk Minimization](/img/14/8d6a76b79a2317fa619e6b7bf87f88.png)
[mixup] mixup: Beyond Imperial Risk Minimization

【TCDCN】《Facial landmark detection by deep multi-task learning》
随机推荐
Sorting out dialectics of nature
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
[binocular vision] binocular correction
Organigramme des activités
【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
用MLP代替掉Self-Attention
How do vision transformer work? [interpretation of the paper]
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
The internal network of the server can be accessed, but the external network cannot be accessed
【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
Apple added the first iPad with lightning interface to the list of retro products
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
应对长尾分布的目标检测 -- Balanced Group Softmax
【学习笔记】反向误差传播之数值微分
Replace convolution with full connection layer -- repmlp
C#与MySQL数据库连接
Hystrix dashboard cannot find hystrix Stream solution
[mixup] mixup: Beyond Imperial Risk Minimization
Execution of procedures
【FastDepth】《FastDepth:Fast Monocular Depth Estimation on Embedded Systems》