可以从第n个位置查找啊 比如: CString str = "abcd"; int dex = str.Find(2);
CString str("The waves are still"); int n = str.Find('e', 5);
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;
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.
Find只能顺向查找,有没有函数可以逆向查找的?
CString::Find 有两个多态函数,可以指定位置,也可以重头开始。 int Find( LPCTSTR pstr, int nStart ) const; int Find( LPCTSTR pstr) const;要反向查找,可以用ReverseFind CString 很好用,但也有许多陷阱。
比如:
CString str = "abcd";
int dex = str.Find(2);
int n = str.Find('e', 5);
int Find( TCHAR ch ) const;int Find( LPCTSTR lpszSub ) const;int Find( TCHAR ch, int nStart ) const;int Find( LPCTSTR pstr, int nStart ) const;
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.
int Find( LPCTSTR pstr, int nStart ) const;
int Find( LPCTSTR pstr) const;要反向查找,可以用ReverseFind
CString 很好用,但也有许多陷阱。