C++ String crbegin()30 Aug 2024 | 1 min read The crbegin() function stands for 'reverse beginning'. This function references to the last character of the string. SyntaxConsider a string str. Syntax would be: ParameterThis function does not contain any parameter. Return valueThis function returns the constant iterator pointing to the last character of the string. Example 1Let's see the simple example of crbegin() function: Output: rewolF sutoL This example shows how to reverse the string using crbegin() function. Example 2Output: 54321 This example shows how to get the reverse list using crbegin() function. Next TopicC++ Strings |
C++ String reserve() This function requests a change in capacity. Syntax Consider a string str and l is planned length of the string. Its syntax would be: str.reserve(l); Parameter l is the planned length for the string Note: capacity of the string can be greater than or equal to 'l'. Return value It does not...
1 min read
C++ String pop_back() This function is used to remove a last character of a string, decreasing its length by one. Syntax Consider a string str. Syntax would be : str.pop_back(); Parameters This function does not contain any parameter. Return value This function does not return any value. Example 1 Let's see the simple example. #include<iostream> using namespace std; int...
1 min read
C++ String front() This function is used to reference a first character of the string. Syntax Consider a string str. Syntax would be: char& p = str.front(); Parameter This function does not contain any parameter. Return value It is used to return a reference of the first character. Example 1 Let's see the simple example. #include<iostream> #include<string> using namespace...
1 min read
C++ String erase() This function removes the characters as specified, reducing its length by one. Syntax Consider a string str. Syntax would be: str.erase(pos,len); str.erase(itr); str.erase(first,last); Parameter pos :It defines the position of the character which is to be removed. len :It defines the number of characters to be erased. Itr : It is an iterator...
1 min read
C++ String operator+=() This function is used to extend the string by appending new characters at the end of the string. Syntax Consider two strings str1 and str2. Syntax would be : str1.operator+=(str2); str1.operator+=(ch); str1.operator+=(const char* s); Parameter str2: str2 is a string object which is to be appended. s: s is a pointer to...
1 min read
C++ String swap() This function is used to exchange the values of two string objects. Syntax Consider two strings s1 and s2 , we want to exchange the values of these two string objects. Its syntax would be : s1.swap(s2) Parameters It contains single parameter, whose value is to be exchanged with...
1 min read
C++ String begin() This function gives a reference to the first element. Syntax Consider a string 's' and iterator 'it'. Syntax would be: iterator it = s.begin(); Parameter This function does not contain any parameter. Return value This function does not return any value. Example 1 Let's see the simple example of begin() function. #include<iostream> using namespace std; int...
1 min read
C++ String find_last_of() This function searches the string for the last character that matches any of the character specified in the string. Syntax Consider two strings str1 and str2. Syntax would be : str1.find_last_of(str2); Parameters str : str is the string to be used in searching. pos : It defines the position at...
1 min read
C++ String replace() This function replaces the portion of string that begins at character position pos and spans len characters. Syntax Consider two strings str1 and str2. Syntax would be: str1.replace(pos,len,str2); Parameters str : str is a string object, whose value to be copied in another string object. pos : pos defines the...
2 min read
C++ String rend() The rend() function stands for reverse end. This function points to the first character of the string. Syntax Consider a string 'str' and reverse iterator 'ritr'. Syntax would be: reverse_iterator ritr = str.rend(); Parameter This function does not contain any parameter. Return value It returns a reverse iterator pointing to the...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India