forked from portfoliocourses/cplusplus-example-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherase_function.cpp
40 lines (30 loc) · 929 Bytes
/
erase_function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*******************************************************************************
*
* Program: erase() String Member Function
*
* Description: Examples of removing characters from a string in C++ using the
* erase() string member function.
*
* YouTube Lesson: https://www.youtube.com/watch?v=ux1tQ-zyMUs
*
* Author: Kevin Browne @ https://portfoliocourses.com
*
*******************************************************************************/
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
// 0123456789
string text = "A string with lots of words in it!";
// text.erase(2,7);
// text.erase(2, 100);
// text.erase(2);
// text.erase();
string::iterator iter = text.erase(text.begin() + 2);
cout << *iter << endl;
// text.erase(text.begin(), text.begin() + 9);
// text.erase(text.begin() + 8, text.end());
cout << text << endl;
return 0;
}