<strings> library in C++ STL Last Updated : 21 Aug, 2024 Comments Improve Suggest changes Like Article Like Report Member functions String.constructor : Construct string object (public member function ).String.destructor : String destructor (public member function )String.operator= : String assignment (public member function ) Iterators Begin : Return iterator to beginning (public member function )End : Return iterator to end (public member function )Advance : Increment the iterator position till the specified number mentioned in its arguments.Next : Returns the new iterator that the iterator would point after advancing the positions mentioned in its arguments.Prev() : Returns the new iterator that the iterator would point after decrementing the positions mentioned in its arguments.Inserter : Insert the elements at any position in the container.Rbegin: Return reverse iterator to reverse beginning (public member function )Rend : Return reverse iterator to reverse end (public member function )Cbegin : Return const_iterator to beginning (public member function )Cend : Return const_iterator to end (public member function )Crbegin : Return const_reverse_iterator to reverse beginning (public member function )Crend : Return const_reverse_iterator to reverse end (public member function ) Capacity Size : Return length of string (public member function )Length : Return length of string (public member function )Max_size : Return maximum size of string (public member function )Resize : Resize string (public member function )Capacity : Return size of allocated storage (public member function )Reserve : Request a change in capacity (public member function )Clear : Clear string (public member function )Empty : Test if string is empty (public member function )Shrink_to_fit : Shrink to fit (public member function ) Element access At : Get character in string (public member function )Back : Access last character (public member function )Front : Access first character (public member function ) Modifiers Operator+= : Append to string (public member function )Append : Append to string (public member function )Push_back : Append character to string (public member function )Assign : Assign New value to the string (public member function )Insert : Insert into string (public member function )Erase : Erase characters from string (public member function )Replace : Replace portion of string (public member function )Swap : Swap string values (public member function )Pop_back : Delete last character (public member function ) String operations Operator[]: Get character of string (public member function )C_str : Get C string equivalent (public member function )Data : Get string data (public member function )Get_allocator : Get allocator (public member function )Copy : Copy sequence of characters from string (public member function )Find : Find content in string (public member function )Rfind : Find last occurrence of content in string (public member function )Find_first_of : Find character in string (public member function )Find_last_of : Find character in string from the end (public member function )Find_first_not_of : Find absence of character in string (public member function )Find_last_not_of : Find non-matching character in string from the end (public member function )Substr : Generate substring (public member function )Compare : Compare strings (public member function )sort : Function sorts the elements in ascending order.is_sorted : Checks if the elements in the string (first to last) are sorted in Ascending order.Elements in the string compared using "<" operator. Member constants & Non-member function overloads Npos : Maximum value for size_t (public static member constant )Operator+ : Concatenate strings .Relational operators : Relational operators for string.Swap : Exchanges the values of two strings .Operator>> : Extract string from stream .Operator<< : Insert string into stream .Getline : Get line from stream into string. More Useful Links Recent Articles on C++Coding Practice PlatformMultiple Choice QuestionsAll articles in C++ Category Comment More infoAdvertise with us Next Article <strings> library in C++ STL ayushmaan bansal Follow Improve Article Tags : Misc C++ cpp-string cpp-strings-library Practice Tags : CPPMisc Similar Reads <regex> library in C++ STL Main classes These classes encapsulate a regular expression and the results of matching a regular expression within a target sequence of characters. basic_regex: Regular expression object (class template) sub_match: Identifies the sequence of characters matched by a sub-expression (class template) m 2 min read std::string::insert() in C++ In C++, the string insert() function is used to insert characters or a string at the given position of the string. For example,C++#include <bits/stdc++.h> using namespace std; int main() { string s = "Geeks"; // Inserting another string at the friend // of s s.insert(s.size(), "forGeeks"); cou 4 min read Raw String Literal in C++ A Literal is a constant variable whose value does not change during the lifetime of the program. Whereas, a raw string literal is a string in which the escape characters like ' \n, \t, or \" ' of C++ are not processed. Hence, a raw string literal that starts with R"( and ends in )". The syntax for R 2 min read Converting String into Set in C++ STL Prerequisites: String in C++Set STL in C++ A string is a collection of characters and if we are converting it into a set the only reason can be to check the characters being used without duplicate values. Example: string s="Geeks for Geeks is for Geeks" // G e k s f o r i are characters // set can s 2 min read std::string::find_last_not_of in C++ It searches the string for the first character, from the end of the string, that does not match any of the characters specified in its arguments. Return value : Index of first unmatched character when successful or string::npos if no such character found. Syntax 1: Search for the last character that 6 min read std::string::size() in C++ The std::string::size() function in C++ is a built-in method of the std::string class that is used to determine the number of characters in the string. All characters up to the null character are considered while calculating the size of the string.In this article, we will learn about string::size() 2 min read C++23 Library - <spanstream> Header The <spanstream> header is a new addition to C++ 23 Standard Libraries Collection. It provides fixed character buffer streams for input and output. It is a collection of classes and function templates that let you manipulate letter stretch as if they were streams, much like <stringstream 3 min read std::string::data() in C++ The data() function writes the characters of the string into an array. It returns a pointer to the array, obtained from conversion of string to the array. Its Return type is not a valid C-string as no '\0' character gets appended at the end of array. Syntax: const char* data() const; char* is the po 2 min read std::string::replace() in C++ The string::replace() function in C++ is used to replace a single or multiple characters from a given index. It is the member function of std::string class. In this article, we will learn how to use the string::replace() function in our C++ program.SyntaxThe string::replace() function provides 6 dif 6 min read std::basic_string::operator[] in C++ Returns a reference to the character at specified location pos. No bounds checking is performed. If pos > size(), the behavior is undefined. Syntax : reference operator[] (size_type pos); const_reference operator[] (size_type pos) const; Parameters : pos - position of the character to return Retu 1 min read Like