C++ String crbegin
The crbegin function is short for 'constant reverse begin'. It points to the final character of the string.
Syntax
Consider a string str. Syntax would be:
str.crbegin();
Parameter
This function does not contain any parameter.
Return value
This function provides the constant iterator that points to the final character within the string.
Example 1
Explore a basic illustration showcasing the crbegin function:
#include<iostream>
using namespace std;
int main()
{
string str =?Lotus Flower?;
for(auto i=str.crbegin();i!=str.end();i++)
{
cout<<*I;
}
return 0;
}
Output:
rewolF sutoL
This illustration demonstrates how to invert a string by utilizing the crbegin function.
Example 2
#include<iostream>
using namespace std;
int main()
{
list<int> li(1,2,3,4,5);
for(auto i =li.crbegin();i!=end();i++)
{
cout<<*i;
}
return 0;
}
Output:
This illustration demonstrates how to obtain the inverted list utilizing the crbegin method.