find_last_of(): Find the last position of a character of a C string. It returns the
index of the last occurrence.
Starting from __pos searches backward for one of the characters
of __s within this string. If found, returns the index where it was found.
If not found, returns npos.
Parameters:
__s – C string containing characters to locate.
__pos – Index of character to look back from (default end).
Syntax:
str.find_last_of(__s , __pos)
For Example:
str = "abcdefffb"
str.find_last_of("a") = > It returns 0.
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){string str = "abcdefffb";cout << str.find_last_of("a") << "\n";return 0;}
No comments:
Post a Comment