您好,欢迎来到年旅网。
搜索
您的当前位置:首页CString的用法

CString的用法

来源:年旅网

Find
CString s( "abcdef" );
ASSERT( s.Find( 'c' ) == 2 );
ASSERT( s.Find( "de" ) == 3 );
// Second example demonstrating
// CString::Find( TCHAR ch, int nStart )
CString str("The stars are aligned");
int n = str.Find('e', 5);
ASSERT(n == 12);

找不到会返回-1。

Insert

CString str("HockeyBest");
int n = str.Insert(6, " is ");
结果为:Hockey is Best

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

Mid
CString s( _T("abcdef") );
ASSERT( s.Mid( 2, 3 ) == _T("cde") );

ASSERT( s.Mid( 2 ) == _T("cdef") );

Right
CString s( _T("abcdef") );
ASSERT( s.Right(2) == _T("ef") );


Replace
CString strZap("C--");
int n = strZap.Replace('-', '+');
ASSERT(n == 2);
ASSERT(strZap == "C++");

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务