Skip to content

Commit

Permalink
added strings in cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravWalia19 committed Jan 3, 2019
1 parent ea73609 commit d253bf0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
38 changes: 38 additions & 0 deletions C++/Data-Structures/STRING/Strings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
2 changes: 2 additions & 0 deletions C++/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#### STRING

* [Strings](Data-Structures/STRING/Strings.cpp)

#### LISTS

* SINGLE
Expand Down
1 change: 1 addition & 0 deletions datastructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Indexer for Data Structures Lover
* docs
* implementation
* [C](C/Data-Structures/STRING/String.c)
* [C++](C++/Data-Structures/STRING/Strings.cpp)
* [JAVA](Java/Data-Structures/STRING/Strings.java)
* complexity

Expand Down
8 changes: 6 additions & 2 deletions docs/complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ This page contains the complexities of different algorithms in this repository.
* [HEAPED 3D ARRAY](#dynamic-3d-arrays-(CC++))
* [JAGGED ARRAY](#jagged-array)
* [STRING](#string)
* [Strings in C]
* [Strings in C++]
* [Strings in C](#strings-in-c)
* [Strings in C++](#strings-in-cpp)
* [Strings in JAVA](#strings-in-java)
* [LISTS](#lists)
* SINGLE
Expand Down Expand Up @@ -333,6 +333,10 @@ This page contains the complexities of different algorithms in this repository.

### STRING

#### Strings in C

#### Strings in CPP

#### Strings in JAVA

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

0 comments on commit d253bf0

Please sign in to comment.