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 clear() This function removes the elements, becomes an empty string. Syntax Consider a string str. Syntax would be: str.clear(); Parameter This function does not contain any parameter. Return value This function does not return any value. Example Let's see a simple example of clear() function: #include<iostream> using namespace std; int main() { stringstr; cout<<?Enter some lines about javaTpoint and...
1 min read
C++ String crend() The crend() function stands for reverse end. It points to the first character of string and returns constant reverse iterator. Syntax Consider a string s. Syntax would be: const_reverse_iterator itr=s.crendO; Parameter It does not contain any parameter. Return value It returns a constant reverse iterator to the reverse end of...
1 min read
C++ String operator=() This function is used to assign a new value to the string, replacing all the current contents. 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, whose value is to be moved. ch : ch is a character...
1 min read
C++ String size() This function is used to return the length of the string in terms of bytes. It defines the actual number of bytes that conform to the contents of the string object which is not necessarily equal to the capacity. Syntax Consider a string object named...
1 min read
C++ String append() This function is used to extend the string by appending at the end of the current value. Syntax Consider string str1 and str2. Syntax would be : Str1.append(str2); Str1.append(str2,pos,len); Str1.append(str2,n); Parameters str : String object which is to be appended in another string object. pos : It determines the position of the...
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 at() This function is used for accessing individual characters. Syntax Consider a string str. To find the position of a particular character, its syntax would be str.at(pos); Parameters pos : It defines the position of the character within the string. Return value It returns the character specified at that position. Example 1 #include<iostream> 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 max_size() This function returns the maximum length the string can reach due to known system. Syntax Consider a string str. Syntax would be: str.max_size(); Parameters It does not contain any parameter. Return value This function returns the maximum length that string can reach. Example 1 Let's see the simple example. #include<iostream> using namespace std; int main() { string str...
1 min read
C++ String find_first_not_of() This function is used to search the string for the first character that does not match any of the characters specified in the string. Syntax Consider two strings str1 and str2. Syntax would be : str1.find_first_not_of(str2); Parameters str : str is the string to be used in searching. pos :...
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