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

String End Function

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

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

C++ String end

This function is employed to retrieve an iterator that points to the final character within the string.

Syntax

Consider a string 'str' and an iterator 'it'. This would be represented in code as:

Example

iterator it = str.end();

Parameter

This function does not contain any parameter.

Return value

It yields an iterator that points to the conclusion of the string.

Example 1

Let's see the simple example.

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:

Example 2

Let's see an another simple example.

Example

#include<iostream>
using namespace std;
int main()
{
	string str="Welcome to javaCppTutorial";
	for(string::iterator itr=str.begin();itr!=str.end();++itr)
	cout<<*itr;
	return 0;
}

Output:

Output

Welcome to javaCppTutorial

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