-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_modifier_methods.cpp
55 lines (49 loc) · 1.17 KB
/
string_modifier_methods.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
int main()
{
// string a = "Hello";
// string b = "World";
/*
// Concating String
a = a + b;
a += b;
a.append(b);
cout << a << endl
<< b << endl;
*/
/*
// Adding a single character after the string
// a = "HelloA";
// a += "A";
a.push_back('A');
cout << a << endl;
a.pop_back();
cout << a << endl;
*/
/*
// Other Available Methods:
s= -> assign string.
s.assign() -> assign string.
s.erase() -> erase characters from the string.
s.replace() -> replace a portion of the string.
s.insert() -> insert a portion to a specific position.
*/
// a = "Gelo";
// a.assign("Gelo");
// cout << a << endl;
string s = "Hello World";
// s.erase(5, s.size() - 6);
// s.erase(5, 3);
// cout << s << endl;
/*
// Replacing blank space with Underscore
s.replace(5, 1, "_");
s.replace(5, 0, "oo");
cout << s << endl;
*/
// s.replace(5, 0, " Fahad");
s.insert(5, " Fahad");
cout << s << endl;
return 0;
}