Finding the Position of a Character or a String within Another String: find()

Syntax: position = source.find(string_to_find, start_position);

find takes two parameters: the string to find, and the starting position.  It searches till the end of the string. find returns the position at which the item is found or string::npos if the item is not found. Reminder: find returns a value of type string::size_type, so declare the variable to hold the result that way.
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment: