Javatpoint Logo
Javatpoint Logo

C++ String cbegin()

It gives a reference to the first element of the string.

Difference b/w cbegin() and begin()

The only difference between cbegin() and begin() is cbegin() returns the constant iterator pointing to the constant value.


Consider a string str. Its syntax would be:


This function does not contain any parameter.

Return value

This function returns the reference pointing to the first element of the string.

Example 1

Let's see a simple example:

In this example, string 'java tutorial' is displayed using cbegin() function.


java tutorial 

Example 2

Let's see another simple example:



In this example, vector containing integer values are displayed using cbegin().

Next TopicC++ Strings

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA