-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_basics.cpp.cpp
More file actions
107 lines (71 loc) · 1.43 KB
/
string_basics.cpp.cpp
File metadata and controls
107 lines (71 loc) · 1.43 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//assigning the strings and comparing
/*
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str1, str2;
// assign()
str1.assign("Hello");
cout << "After assign str1: " << str1 << endl;
// append()
str1.append(" World");
cout << "After append str1: " << str1 << endl;
// assign second string
str2.assign("Hello World");
cout << "str2: " << str2 << endl;
// compare()
if(str1.compare(str2) == 0)
cout << "Both strings are equal" << endl;
else
cout << "Strings are not equal" << endl;
return 0;
}
*/
//using string and print
/*
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b,c,d,e;
a="sudeep";
b="uppar";
cout<<"the string1 is= "<<a<<endl;
cout<<"the string2 is= "<<b<<endl;
cout<<a+b<<endl;
cout<<a.size()<<endl;
cout<<a.length()<<endl;
cout<<a[0]<<endl;
a.append(" Govind");
cout<<a<<endl;
c="program";
d="program";
if(c==d)
{
cout<<"the strings are equal"<<endl;
}
else
cout<<"not equal"<<endl;
e.assign("from BGK");
cout<<e<<endl;
return 0;
}
*/
// use indexing the string
/*
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b;
a.assign("Sudeep G Uppar");
cout<<a<<endl;
b.assign("from BGK karnataka",9 ,9);
cout<<b<<endl;
cout<<a+" "+b;
}
*/