例如,下面的代码使用std::string::find方法查找字符串中是否含有指定的子字符串。如果找到,将输出子字符串的位置,否则将输出npos。 std::string str = "Hello, World!"; std::string sub_str = "World"; std::size_t pos = str.find(sub_str); if (pos != std::string::npos) std::cout << "...