string::rbegin() and string::rend() in C++ Last Updated : 25 Sep, 2024 Comments Improve Suggest changes Like Article Like Report The std::string::rbegin() and std::string::rend() functions in C++ are used to fetch the reverse iterators to the string. They are the member function of std::string and are used when we want to iterate the string in reverse. In this article, we will learn how to use string::rbegin() and string::rend() in C++.string::rbegin()The string::rbegin() function returns a reverse iterator pointing to the reverse beginning (i.e. last character) of the string.If we increment the reverse iterator, it will move from right to left in the string i.e. it will move from last to second last and so on. It is just opposite to the normal string iterators.Syntaxstr.rbegin()where str is the name of the string.ParameterThis function does not accept any parameter.Return valueIt returns a reverse iterator pointing to the last character in the string.string::rend()The string::rend() is a reverse iterator pointing to the reverse end (i.e. theoretical character which is just before the first character) of the string.Syntaxstring_name.rend()ParameterThis function does not accept any parameter.Return valueIt returns a reverse iterator pointing to the theoretical character before the first character in the string.Example of string::rbegin() and string::rend() C++ // C++ program to illustrate the use of // string::rbegin() and string::rend() function #include <bits/stdc++.h> using namespace std; int main() { string s = "GfG htiW ecitcarP"; // Printing the character of string in // reverse order for (auto it = s.rbegin(); it != s.rend(); it++) cout << *it; return 0; } OutputPractice With GfG Comment More infoAdvertise with us Next Article string::rbegin() and string::rend() in C++ A anmolpanxq Follow Improve Article Tags : C++ cpp-iterator STL cpp-string Practice Tags : CPPSTL Similar Reads vector rbegin() and rend() Functions in C++ STL In C++, std::vector::rbegin() and std::vector::rend() are built-in functions used to retrieve reverse iterators to the reverse beginning and reverse end of a vector. These functions allow easy traversal of vectors in reverse i.e. from the last element to the first. They are the member functions of t 3 min read std::string::resize() in C++ resize() lets you change the number of characters. Here we will describe two syntaxes supported by std::string::resize() in C++ Return Value : None Syntax 1: Resize the number of characters of *this to num. void string ::resize (size_type num) num: New string length, expressed in number of character 3 min read array::rbegin() and array::rend() in C++ STL array::rbegin() is a built-in function in C++ STL which returns a reverse iterator pointing to the last element in the container. Syntax:array_name.rbegin()Parameters: The function does not accept any parameter. Return value: The function returns a reverse iterator pointing to the last element in th 2 min read std::string::append() in C++ The string::append() in C++ is used append the characters or the string at the end of the string. It is the member function of std::string class .The string::append() function can be used to do the following append operations:Table of ContentAppend a Whole StringAppend a Part of the StringAppend a C 3 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 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::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 Tokenizing a string in C++ Tokenizing a string denotes splitting a string with respect to some delimiter(s). There are many ways to tokenize a string. In this article four of them are explained:Using stringstreamA stringstream associates a string object with a stream allowing you to read from the string as if it were a stream 4 min read How to Print String Literal and Qstring With Qdebug in C++? Printing string literals and QString with QDebug in C++ can be a useful tool for debugging. By printing out the contents of a string or QString, you can quickly identify any issues that may be present in your code. In this article, weâll discuss how to print string literals and QString with QDebug i 2 min read Like