Javatpoint Logo
Javatpoint Logo

C++ String Find()

This function is used for finding a specified substring.


Consider two strings str1 and str2. Syntax would be :


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 string to be searched for.

ch : It defines the character to search for.

Return value

It returns the position of the first character of first match.

Example 1

Let's see the simple example.


Java is the best programming language
Position of the programming word is 17

Example 2

Let's see simple example by passing position of a character as a parameter.


Mango is my favorite fruit
Position of fruit is 21

Example 3

Let's see simple example of finding a single character.


String contains : javatpoint
         Position of p is 5

Next TopicC++ Strings

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA