Javatpoint Logo
Javatpoint Logo

C++ String Find()

This function is used for finding a specified substring.

Syntax

Consider two strings str1 and str2. Syntax would be :

Parameters

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.

Output:

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.

Output:

Mango is my favorite fruit
Position of fruit is 21

Example 3

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

Output:

String contains : javatpoint
         Position of p is 5

Next TopicC++ Strings





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA