VC编程CString用法大全(转载)

2012-02-13 21:42:08|?次阅读|上传:wustguangh【已有?条评论】发表评论

关键词:C/C++, 字符处理|来源:唯设编程网

15.CString::TrimRight

void TrimRight( );

void CString::TrimRight( TCHAR chTarget );

void CString::TrimRight( LPCTSTR lpszTargets ); 

说明:用法类似于上面。  

16.CString::Compare

int Compare( LPCTSTR lpsz ) const; 

返回值:字符串一样返回0,小于lpsz  返回-1,大于lpsz  返回1, 区分大小字符

示例:

CString s1( "abc" );

CString s2( "abd" );

ASSERT( s1.Compare( s2 ) == -1 );

ASSERT( s1.Compare( "abe" ) == -1  

17.CString::CompareNoCase

int CompareNoCase( LPCTSTR lpsz ) const; 

返回值: 字符串一样 返回0,小于lpsz  返回-1,大于lpsz  返回1,不区分大小字符

18.CString::Collate

int Collate( LPCTSTR lpsz ) const; 

同CString::Compare  

19.CString::CollateNoCase

int CollateNocase( LPCTSTR lpsz ) const; 

同CString::CompareNoCase

20.CString::CString      //构造函数

CString( );

CString( const CString& stringSrc ); 

CString( TCHAR ch, int nRepeat = 1 ); 

CString( LPCTSTR lpch, int nLength );

CString( const unsigned char* psz ); 

CString( LPCWSTR lpsz );

CString( LPCSTR lpsz ); 

示例:

CString s1;                     

CString s2( "cat" );              

CString s3 = s2;                 

CString s4( s2 + " " + s3 );        

 // s5 = "x"
CString s5( 'x' );                     

// s6 = "xxxxxx"
CString s6( 'x', 6 );                   

// s7 = "Create a new document"
CString s7((LPCSTR)ID_FILE_NEW);       

CString city = "Philadelphia"; 
发表评论0条 】
网友评论(共?条评论)..
VC编程CString用法大全(转载)