-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRevisiting_String.cpp
58 lines (47 loc) · 1.1 KB
/
Revisiting_String.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
56
57
58
#include<bits/stdc++.h>
using namespace std;
int main()
{
// string name = "Lokesh Singh";
// cout<<name<<endl;
string name = "Lokesh";
string sur_name = " Singh";
// cout<<"Enter your name\n";
// cin>>name;
// cout<<"Your name is : "<<name<<endl;
cout<<"The length of string is : "<<name.length()<<endl;
// cout<<name[0]<<endl;
// cout<<name[10]<<endl;
// cout<<name[7]<<endl;
// cout<<name[5]<<endl;
// cout<<name+sur_name<<endl;
// String Functions
// 1) size
// cout<<"The size of string is : "<<name.size()<<endl;
// 2) append
// cout<<name.append(sur_name)<<endl;
// 3) length
// cout<<"The length of string is : "<<name.length()<<endl;
// 4) swap
// swap(name,sur_name);
// cout<<name<<endl;
// cout<<sur_name<<endl;
// 5) clear
// cout<<name<<endl;
// name.clear();
// cout<<name<<endl;
// 6) empty
// cout<<name<<endl;
// name.clear();
// cout<<name.empty()<<endl;
// 7) erase
// cout<<name<<endl;
// name.erase();
// cout<<name<<endl;
// 8) find
// int found = name.find("esh");
// cout<<found<<endl;
// name.erase(name.begin()+found);// It deletes the given index character
// cout<<name<<endl;
return 0;
}