C++文字列内で特定の文字を検索

595 ワード

C++文字列内で特定の文字を検索
文字列内の特定の文字の検索とは、文字列内に指定された文字または文字セットが存在するかどうかを検索することです.
#include 

int main(int argc,const char* argv[])
{
	std::string str1 = "Hello World!";
	//find_first_of(char)     str1         o,    ,          o   
	std::cout << str1.find_first_of('o') << std::endl;

	std::string str2 = "World!";
	//       str1          str2    ,    ,            str2        。
	std::cout <