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

String Crbegin Function

BLUF: Mastering String Crbegin 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 Crbegin Function

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

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:

Example

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:

Example

#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:

Output

rewolF sutoL

This illustration demonstrates how to invert a string by utilizing the crbegin function.

Example 2

Example

#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.

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