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

String Cend Function

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

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

C++ String cend

This function provides a pointer to the final character within the string.

Difference b/w end and cend

The sole contrast between end and cend function lies in the fact that cend yields a constant iterator indicating the constant value.

Syntax

Consider a string str. Syntax would be:

Example

str.cend();

Parameter

This function does not contain any parameter.

Return value

This function provides the reference to the final element of the string.

Example 1

Example

#include<iostream>
using namespace std;
int main()
{
	string str ="mango is my favorite fruit";
	fot(auto i=str.cbegin();i!=str.cend();i++)
	{
		cout<<*i;
	}
	return 0;
}

Output:

Output

mango is my favorite fruit

This instance showcases the string through the utilization of the cbegin method.

Example 2

Example

#include<iostream>
using namespace std;
int main()
{
list<int> li(1,2,3,4,5);
for(auto i=li.cbegin();i!=cend();++i)
cout<<*i
}

Output:

This example demonstrates the list utilizing the cbegin and cend functions.

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