-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring02.cpp
More file actions
54 lines (44 loc) · 1.2 KB
/
Copy pathstring02.cpp
File metadata and controls
54 lines (44 loc) · 1.2 KB
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
/* concatination is simply done by + */
#include <iostream>
#include <string>
using namespace std;
int main(){
string prompt = "enter two lines\n",
line1, line2, key = "y";
while(key == "y" || key == "Y"){
cout << prompt;
getline(cin, line1);
getline(cin, line2);
if (line1 == line2)
puts("both same");
else{
puts("smaller line");
cout << ((line1 < line2) ? line1 : line2 ) << endl;
/* the len. */
int len1 = line1.length(),
len2 = line2.length();
if (len1 == len2)
puts("both have same length");
else{
puts("not same");
}
}
puts("\nwanna repeat [y/n] ?");
do
getline(cin, key);
/* cause the key is stored as str */
while(key != "y" && key != "Y" && key != "n" && key != "N");
}
/* insert & erase */
string s1("miss summer");
s1.insert(5, "ashley ");
cout << s1 << endl;
string s2("the summer-time");
s2.erase(4, 7);
cout << s2 << endl;
/* cut the o/p */
s2.erase(3);
// s2.erase();
cout << s2 << endl;
return 0;
}