C++ String rbegin
The rbegin method represents the reverse start. It is utilized to reference the final character within the string.
Syntax
Consider a string str. Syntax would be:
Example
reverse_iterator itr = str.rbegin();
Parameter
This function does not contain any parameter.
Return value
It yields the reverse iterator indicating the final character of the string.
Example
Let's see the simple example.
Example
#include<iostream>
using namespace std;
int main()
{
string str="Dancing is my hobby";
for(string::reverse_iterator itr=str.rbegin();itr!=str.rend();++itr)
cout<<*itr;
return 0;
}
Output:
Output
ybboh ym si gnicnaD
In this instance, we obtain the inverted string by utilizing the rbegin function.