String Crend Function - C++ Programming Tutorial
C++ Course / Strings / String Crend Function

String Crend Function

BLUF: Mastering String Crend Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: String Crend Function

C++ is renowned for its efficiency. Learn how String Crend Function enables low-level control and high-performance computing in the tutorial below.

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:

Example

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.

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 instance, we obtained the inverted string by utilizing the 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 instance, we obtained the inverted string that holds numerical values by employing the crend function.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience