Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d253bf0

Browse files
added strings in cpp
1 parent ea73609 commit d253bf0

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
int main()
5+
{
6+
string str;
7+
cout << "Enter any string"<<endl;
8+
getline(cin,str);
9+
cout << "Entered String: " << str << endl;
10+
11+
if(str=="hello world")
12+
{
13+
cout << "It is equal to hello world" << endl;
14+
}
15+
else
16+
{
17+
cout << "It is not equal to hello world" << endl;
18+
}
19+
20+
cout << "String length: "<<str.length() << endl;
21+
cout << "String with append: " << str.append("hello") << endl;
22+
23+
str.push_back('a');
24+
cout << str << endl;
25+
str.pop_back();
26+
cout << str << endl;
27+
28+
cout << "CAPACITY: " << str.capacity() << endl;
29+
30+
string str1="anonymous";
31+
cout << "str: " << str << endl;
32+
cout << "str1: "<< str1 << endl<<endl;
33+
34+
str.swap(str1);
35+
cout << "After swapping function" << endl;
36+
cout << "str: " << str << endl;
37+
cout << "str1: "<<str1 << endl;
38+
}

‎C++/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#### STRING
2424

25+
* [Strings](Data-Structures/STRING/Strings.cpp)
26+
2527
#### LISTS
2628

2729
* SINGLE

‎datastructures.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Indexer for Data Structures Lover
8989
* docs
9090
* implementation
9191
* [C](C/Data-Structures/STRING/String.c)
92+
* [C++](C++/Data-Structures/STRING/Strings.cpp)
9293
* [JAVA](Java/Data-Structures/STRING/Strings.java)
9394
* complexity
9495

‎docs/complexity.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ This page contains the complexities of different algorithms in this repository.
6565
* [HEAPED 3D ARRAY](#dynamic-3d-arrays-(CC++))
6666
* [JAGGED ARRAY](#jagged-array)
6767
* [STRING](#string)
68-
* [Strings in C]
69-
* [Strings in C++]
68+
* [Strings in C](#strings-in-c)
69+
* [Strings in C++](#strings-in-cpp)
7070
* [Strings in JAVA](#strings-in-java)
7171
* [LISTS](#lists)
7272
* SINGLE
@@ -333,6 +333,10 @@ This page contains the complexities of different algorithms in this repository.
333333

334334
### STRING
335335

336+
#### Strings in C
337+
338+
#### Strings in CPP
339+
336340
#### Strings in JAVA
337341

338342
SNo. | Methods | Order of complexity O(n) | Type of Complexity

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /