![]() |
VOOZH | about |
The std::string::rfind is a string class member function that is used to search the last occurrence of any character in the string. If the character is present in the string then it returns the index of the last occurrence of that character in the string else it will return string::npos which denotes the pointer is at the end of the string. Header File:
#include < string >
rfind(char ch) rfind(string str)
Parameters: This function takes a given character or a string as a parameter, whose index is to be found. Return value: This method returns the position of the last occurrence of that character or first index of the last occurrence of the string. Program 1: Below is the program to illustrate string::rfind(char ch):
Program 2: Below is the program to illustrate string::rfind(string str):
rfind(char ch, size_t position); rfind(string s, size_t position);
Parameters: This function takes:
Return value: This method returns the position of the first character of the last match of that given character or string before that position else it returns string::npos Program 3: Below is the program to illustrate string::rfind(char ch, size_t position):
Program 4: Below is the program to illustrate string::rfind(string str, size_t position):