-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStrings.cpp
38 lines (32 loc) · 892 Bytes
/
Strings.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
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
cout << "Enter any string"<<endl;
getline(cin,str);
cout << "Entered String: " << str << endl;
if(str=="hello world")
{
cout << "It is equal to hello world" << endl;
}
else
{
cout << "It is not equal to hello world" << endl;
}
cout << "String length: "<<str.length() << endl;
cout << "String with append: " << str.append("hello") << endl;
str.push_back('a');
cout << str << endl;
str.pop_back();
cout << str << endl;
cout << "CAPACITY: " << str.capacity() << endl;
string str1="anonymous";
cout << "str: " << str << endl;
cout << "str1: "<< str1 << endl<<endl;
str.swap(str1);
cout << "After swapping function" << endl;
cout << "str: " << str << endl;
cout << "str1: "<<str1 << endl;
}