O'Reilly logo

Beginning C++ Programming by Richard Grimes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching strings

The find method is passed using either a character, a C string, or a C++ string, and you can provide an initial search position to start the search. The find method returns the position (rather than an iterator) to where the search text was located, or a value of npos if the text cannot be found. The offset parameter, and a successful return value from the find method, enables you to parse a string repeatedly to find specific items. The find method searches for the specified text in the forward direction, and there is also an rfind method that performs the search in the reverse direction.

Note that rfind is not the complete opposite of the find method. The find method moves the search point forward in the string and at each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required