STL
In this lesson, we'll see how to use string in C++.
We'll cover the following...
C++
Though strings can be represented as an array of characters, most languages have a separate type for strings.
Include statement: #include <string>
Let’s see the string type in C++ and some of its methods that we will be using frequently.
The entire documentation can be found here.
string s; // new empty string
s.size(); // get size()
s[i]; // access character
Time complexity
The string data type is an array of characters and hence the operations are very similar to that on a vector; memory, time and name-wise. Points to note are
- Inserting at the end -
- Inserting in between -