find_first_of(): Find the position of a character of a C string. It returns the
index of the first occurrence.
Starting from __pos searches forward 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 – String containing characters to locate.
__pos – Index of character to search from (default 0).
Syntax:
str.find_first_of(__s , __pos)
For Example:
str = "abcbbabc"
str.find_first_of("b",2) => It returns 3.
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){string str = "abcbbabc";cout << str.find_first_of("b", 2) << "\n";return 0;}
No comments:
Post a Comment