例如,"abcdefg"中包含  "cde"  但不包含 "cdf"???用CString里有没有这样的函数,有没有代码示例???

解决方案 »

  1.   

    就是用CString类里面的Find 和FindOneOf两个函数啊。
    具体代码偶就不写了:)
      

  2.   

    // First example demonstrating 
    // CString::Find ( TCHAR ch )
    CString s( "abcdef" );
    ASSERT( s.Find( 'c' ) == 2 );
    ASSERT( s.Find( "de" ) == 3 );// Second example demonstrating 
    // CString::Find( TCHAR ch, int nStart )
    CString str("The stars are aligned");
    int n = str.Find('e', 5);
    ASSERT(n == 12);
      

  3.   

    CString str="abcdefg";
    int indx=str.Find("cde");
    if(indx==-1)
      MessageBox("未找到指定字符");
    else
      MessageBox("找到指定字符!");