string end() in C++

end(): It returns a read/write iterator that points one past the last 

character in the string.

Parameter: No parameters are required for this function.

Syntax:

string :: iterator it =str.end()

For Example:

str ="abc"

str.end() => It points beyond the last character of the string

Approach

C++

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

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

    string ::iterator it = str.end();

    cout << *(it - 1<< "\n";

    return 0;
}

No comments:

Post a Comment