C++ String crend
The crend function stands for reverse end. Icpp tutorials to the first character of string and returns constant reverse iterator.
Syntax
Consider a string s. Syntax would be:
Example
const_reverse_iterator itr=s.crendO;
Parameter
It does not contain any parameter.
Return value
It returns a constant reverse iterator to the reverse end of the string.
Example 1
Let's see a simple example.
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:
Output
gnimmargorP C
In this example, we got the reverse string using crend function.
Example 2
Let's see another simple example.
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 example, we got the reverse string containing integer values using crend function.