C++ String rend()30 Aug 2024 | 1 min read The rend() function stands for reverse end. This function points to the first character of the string. SyntaxConsider a string 'str' and reverse iterator 'ritr'. Syntax would be: ParameterThis function does not contain any parameter. Return valueIt returns a reverse iterator pointing to the beginning of the string. ExampleLet's see the simple example. Output: dlroW olleH In this example, we get the reverse string using rend() function. Next TopicC++ Strings |
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. Syntax Consider a string str. Its syntax would be: str.cbegin(); Parameter This function does not contain...
1 min read
C++ String operator[]() This function is used to get a character at position pos in the string. Syntax Consider a string 'str' and character 'ch' at position 'pos'. Syntax would be: char ch = str.operator[ ](pos); Parameter pos: It defines the position of character which is to be retrieved. Return value This function returns...
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
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 Find() This function is used for finding a specified substring. Syntax Consider two strings str1 and str2. Syntax would be : str1.find(str2); Parameters str : String to be searched for. pos : It defines the position of the character at which to start the search. n : Number of characters in a...
1 min read
C++ String end() This function is used to return an iterator pointing to the last character of the string. Syntax Consider a string 'str' and an iterator 'it'. Syntax would be: iterator it = str.end(); Parameter This function does not contain any parameter. Return value It returns an iterator pointing to the end of...
1 min read
C++ String c_str() This function returns a pointer to an array that contains null terminated sequence of characters. Syntax Consider a string str. Syntax would be: str.c_str(); Parameter It does not contain any parameter. Return value It returns a pointer to the c-string representation of the string object's value. Example Let's see the simple example. #include<iostream> #include<cstring> #include<string> using...
1 min read
C++ String find_last_not_of() This function is used to search the string for the last character that does not match with any of the character specified in the string. Syntax Consider two strings str1 and str2. Its syntax would be : str1.find_last_not_of(str2); Parameters str : str is the string to be used in...
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 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
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