回覆列表
  • 1 # rrzpi23258

    查詢(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

  • 2 # 藍風24

    查詢(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

    else

    cout

  • 中秋節和大豐收的關聯?
  • 世事無常,從你記事開始你遇到最困難的時刻是什麼時候?