That's not a tutorial. That's a concise explanation of what the string class function
find does. If you're ever going to get anywhere in programming, you're going to have to be able to read function descriptions.
1 2 3 4
|
size_t find ( const string& str, size_t pos = 0 ) const;
size_t find ( const char* s, size_t pos, size_t n ) const;
size_t find ( const char* s, size_t pos = 0 ) const;
size_t find ( char c, size_t pos = 0 ) const;
| |
This is a set or prototypes for this function. As you can see, there are four forms of this function. The first one accepts two input variables, one a
const string& and the other a
size_t object. The
size_t input has a default value if you don't provide one.
The other function prototypes are also quite simple.
So now read what he function actually does.
| Searches the string for the content specified in either str, s or c, and returns the position of the first occurrence in the string. |
Hey, great, that's what you need. You want to look for the word "good". Let's see how we can use this. Let's take the first form.
size_t find ( const string& str, size_t pos = 0 ) const;
This is a class function, so it will be called on an object of type string, like this:
someString.find(str, pos);
Are you following this? Here is a different reference tot he same function:
http://en.cppreference.com/w/cpp/string/basic_string/find