C++ String find_first_of()This function is used for finding the location of first occurrence of the specified characters. SyntaxConsider string str1 and str. Syntax would be : Parametersstr : string containing characters to be searched for. pos : It defines the position at which to start the search. n : Number of characters identifying characters to be searched for. ch : It defines the character which is to be searched Return valueIt returns the position of the searched character. Examples 1Let's see the simple example. Output: String contains : Dancing is my favorite hobby Position of the first occurrence of the string favorite is 1 Examples 2Let's see the simple example when the position at which to start the search is specified. Output: String contains : Welcome to the programming world Now, start the search from the second position and we find the first occurrence of the 'programming' is : 4 Examples 3Let's see the simple example to find the position of the first occurrence of a single character. Output: String contains javatpoint tutorial Position of the first occurrence of 'a' character is : 1 Next TopicC++ Strings |
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