CString经验

CString经验

string 变为 CString :

      string   str;

CString  cstr = str.c_str();

////////////////////////////////////////////////////////////

CString中查找子串:

      CString  cstr.Find(_T(“abc”));

///////////////////////////////////////////////////////////

截取CString :

      CString  to_cut, result;

      result = to_cut.Mid(0, to_cut.GetLength() / 2);

////////////////////////////////////////////////////////////

CString::Left

CString Left( int nCount ) const; 

throw( CMemoryException );

返回的字符串是前nCount个字符。

例子

CString s( _T("abcdef") );

ASSERT( s.Left(2) == _T("ab") );

//////////////////////////////////////////////////////////////

CString::MakeUpper

void MakeUpper( );

改变字符的大写

//////////////////////////////////////////////////////////////

CString::MakeLower

void MakeLower( );

改变字符的小写

//////////////////////////////////////////////////////////////

CString::Replace

int Replace( TCHAR chOld, TCHAR chNew );

int Replace( LPCTSTR lpszOld, LPCTSTR lpszNew );

//////////////////////////////////////////////////////////////

CString::MakeReverse

void MakeReverse( );

字符倒置

//////////////////////////////////////////////////////////////

CString::ReverseFind

int ReverseFind( TCHAR ch ) const;

返回值

返回此CString 对象中与要求的字符匹配的最后一个字符的索引;如果没有找

到需要的字符则返回-1。

//////////////////////////////////////////////////////////////

原文地址:https://www.cnblogs.com/johnpher/p/2570645.html