查詢(find)語法: size_type find( const basic_string &str, size_type index ); size_type find( const char *str, size_type index ); size_type find( const char *str, size_type index, size_type length ); size_type find( char ch, size_type index );find()函式: 返回str在字串中第一次出現的位置(從index開始查詢)。如果沒找到則返回string::npos, 返回str在字串中第一次出現的位置(從index開始查詢,長度為length)。如果沒找到就返回string::npos, 返回字元ch在字串中第一次出現的位置(從index開始查詢)。如果沒找到就返回string::npos 例如, string str1( "Alpha Beta Gamma Delta" ); unsigned int loc = str1.find( "Omega", 0 ); if( loc != string::npos ) cout
查詢(find)語法: size_type find( const basic_string &str, size_type index ); size_type find( const char *str, size_type index ); size_type find( const char *str, size_type index, size_type length ); size_type find( char ch, size_type index );find()函式: 返回str在字串中第一次出現的位置(從index開始查詢)。如果沒找到則返回string::npos, 返回str在字串中第一次出現的位置(從index開始查詢,長度為length)。如果沒找到就返回string::npos, 返回字元ch在字串中第一次出現的位置(從index開始查詢)。如果沒找到就返回string::npos 例如, string str1( "Alpha Beta Gamma Delta" ); unsigned int loc = str1.find( "Omega", 0 ); if( loc != string::npos ) cout