轉載:https://blog.csdn.net/frivolousinstant/article/details/52796922
ReverseFind
CString::ReverseFind
ReverseFind | 在一個較大的字符串中從末端開始查找某個字符 |
CString::ReverseFind
int ReverseFind( TCHAR ch ) const;
返回值:
返回此CString對象中與要求的字符匹配的最后一個字符的索引;如果沒有找到需要的字符則返回-1。
說明:
此成員函數在此CString對象中搜索與一個子串匹配的最后一個字符。此函數類似於運行時函數strrchr。
示例:// CString::ReverseFind示例:
CString s( "abcabc" );
ASSERT( s.ReverseFind( 'b' ) == 4 );
CString——Left、Right、Find、ReverseFind
CString::Left(intnCount)
——返回字符串前nCount個字符的字符串
example:
CString str(_T("Shop,車間"));
str = str.Left(4);
結果:str="Shop";
CString::Right(int nCount)
——返回字符串后nCount個字符的字符串
example:
CString str(_T("Shop,車間"));
str = str.Right(2);
結果:str="車間";
CString::Find(_T(","))
返回“,”在字符串中的索引值
example:
CString str(_T("Shop,車間"));
int idex = str.Find(_T(","));
此時:idex=4;
宗:要想獲得“,”右側內容
str = str.Right(str.GetLength()-1-str.Find(_T(",")));
其中:
str.GetLength()=7;
-1排除“,”
-str.Find(_T(","))排除“,”前的所有字
CString::ReverseFind
int ReverseFind( TCHAR ch ) const;
返回值:
返回此CString對象中與要求的字符匹配的最后一個字符的索引;如果沒有找到需要的字符則返回-1。
參數: ch 要搜索的字符。
說明:
此成員函數在此CString對象中搜索與一個子串匹配的最后一個字符。此函數類似於運行時函數strrchr。
示例:// CString::ReverseFind示例:
CString s( "abcabc" );
ASSERT( s.ReverseFind( 'b' ) == 4 );
CString::Left(intnCount)
——返回字符串前nCount個字符的字符串
example:
CString str(_T("Shop,車間"));
str = str.Left(4);
結果:str="Shop";
CString::Right(int nCount)
——返回字符串后nCount個字符的字符串
example:
CString str(_T("Shop,車間"));
str = str.Right(2);
結果:str="車間";
CString::Find(_T(","))
返回“,”在字符串中的索引值
example:
CString str(_T("Shop,車間"));
int idex = str.Find(_T(","));
此時:idex=4;
宗:要想獲得“,”右側內容
str = str.Right(str.GetLength()-1-str.Find(_T(",")));
其中:
str.GetLength()=7;
-1排除“,”
-str.Find(_T(","))排除“,”前的所有字
CString::ReverseFind
int ReverseFind( TCHAR ch ) const;
返回值:
返回此CString對象中與要求的字符匹配的最后一個字符的索引;如果沒有找到需要的字符則返回-1。
參數: ch 要搜索的字符。
說明:
此成員函數在此CString對象中搜索與一個子串匹配的最后一個字符。此函數類似於運行時函數strrchr。
示例:// CString::ReverseFind示例:
CString s( "abcabc" );
ASSERT( s.ReverseFind( 'b' ) == 4 );