string crbegin() in C++

crbegin(): It returns a read-only (constant) reverse iterator that points to 

the last character in the string. 

Note: Iteration is done in reverse element order. 

This function is available in the below file.

File: basic_string.h

Parameter: No parameters are required for this function.

Syntax:

string :: const_reverse_iterator it = str.crbegin()

For Example:

str = "abc"

str.crbegin() = > It points to the last element (i.e c)

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str = "abc";

    string ::const_reverse_iterator it = str.crbegin();

    cout << *it << "\n";

    return 0;
}


No comments:

Post a Comment