CString如何实现从某个指定位置开始查找?Find好像只能从0开始查找。

解决方案 »

  1.   

    可以从第n个位置查找啊
    比如:
    CString str = "abcd";
    int dex = str.Find(2);
      

  2.   

    CString str("The waves are still");
    int n = str.Find('e', 5);
      

  3.   

    CString::Find 
    int Find( TCHAR ch ) const;int Find( LPCTSTR lpszSub ) const;int Find( TCHAR ch, int nStart ) const;int Find( LPCTSTR pstr, int nStart ) const;
      

  4.   


    MSDN:int Find( LPCTSTR pstr, int nStart ) const;nStartThe index of the character in the string to begin the search with, or 0 to start from the beginning. The character at nStart is excluded from the search if nStart is not equal to 0.
      

  5.   

    Find只能顺向查找,有没有函数可以逆向查找的?
      

  6.   

    CString::Find 有两个多态函数,可以指定位置,也可以重头开始。
    int Find( LPCTSTR pstr, int nStart ) const;
    int Find( LPCTSTR pstr) const;要反向查找,可以用ReverseFind 
    CString 很好用,但也有许多陷阱。