C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ String end()This function is used to return an iterator pointing to the last character of the string. Syntax
Consider a string 'str' and an iterator 'it'. Syntax would be: iterator it = str.end(); Parameter
This function does not contain any parameter. Return valueIt returns an iterator pointing to the end of the string. Example 1
Let's see the simple example.
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str="Java is an object oriented programming language";
string::iterator it =str.end();
cout<<*(it-1);
return 0;
}
Output: e Example 2Let's see an another simple example.
#include<iostream>
using namespace std;
int main()
{
string str="Welcome to javaTpoint";
for(string::iterator itr=str.begin();itr!=str.end();++itr)
cout<<*itr;
return 0;
}
Output: Welcome to javaTpoint
Next TopicC++ Strings
|