application of Find () in string (RFind () similar, only from reverse lookup)The prototype is as follows:(1) size_t find (const string& str, size_t pos = 0) const; Find object--string Class object(2) size_t find (const char* s, size_t pos = 0) const;//Find Object--string(3) size_t find (const char* s, size_t pos, size_t N) const; Find Object--the first n characters of a string(4) size_t find (char c, size_t pos = 0) const; Find objects--charactersResult: Found--Returns the index of the first characternot found--return to String::npos
other find_first_of (), find_last_of (), find_first_not_of (), find_last_not_of ()The function is to find a search condition that satisfies any character in a stringstring Snake1 ("Cobra");int where = snake1.find_first_of ("Hark");returns 3 because the first occurrence of a character in "Hark" in Snake1--cobra is the character ' R ' (3 is the index of ' R ' in Cobra)similarly:int where = snake1.find_last_of ("Hark");returns 4 because the last occurrence of one character in "Hark" in Snake1--cobra is the character ' a ' (3 is the index of ' R ' in Cobra)
(reprinted) Summary and example of function usage such as find (), RFind () in C + + string