C++ String crend
The crend function represents the end iterator in reverse. In C++, it points to the element before the first character of a string and provides a constant reverse iterator.
Syntax
Consider a string s. Syntax would be:
const_reverse_iterator itr=s.crendO;
Parameter
It does not contain any parameter.
Return value
It provides a constant reverse iterator pointing to the end of the string in reverse.
Example 1
Let's see a simple example.
#include<iostream>
using namespace std;
int main()
{
string str="C Programming";
for(string::const_reverse_iterator itr=str.crbegin();itr!=str.crend();++itr)
cout<<*itr;
return 0;
}
Output:
gnimmargorP C
In this instance, we obtained the inverted string by utilizing the crend function.
Example 2
Let's see another simple example.
#include<iostream>
using namespace std;
int main()
{
string num="12345";
for(string::const_reverse_iterator itr=num.crbegin();itr!=num.crend();++itr)
cout<<*itr;
return 0;
}
Output:
In this instance, we obtained the inverted string that holds numerical values by employing the crend function.