The find member of the string class finds the position in a string of another string or character. There are several versions of find. E.g. to find a string str as a substring of a string s:
- s.find(str) // start search at position 0 of s
- s.find(str, 0) // start search at position 0 of s
- s.find(str, 4) // start search at position 4 of s
- s.find_first_of(",;") // find position of first comma or semicolon
- s.find_first_of(",;", 4) // start at position 4
- s.find_first_not_of(",;") // find position of first character not a comma and not a semicolon, starting at position 0
Note 1: The position of the first character of a string is 0.
Note 2: If the string or character specified is not found, the return value is a special value defined in the string class:
string::npos
This value is the largest (unsigned) integer value.