?????????:???????????????????
????nIndex??????????????????nCount??????????????????????????ó?????????nCount>??????????????(GetCount() - nIndex)?????????nCount?????????????????????????????С?
?????????
????CString str1??str2??str3;
????char a;
????str1 = "nihao";
????str2 = "nIhao";
????int x;
????// int i=(str1 == str2);
????str1.Delete(2??3);
???????nCount(3) > GetCount() – nIndex (5-2)????д???
????22.CString::Empty
????Void Empty( );
?????????????з???? ??????;
?????????
????CString s( "abc" );
????s.Empty();
????ASSERT( s.GetLength( ) == 0 );
????23.CString::Find
????int Find( TCHAR ch ) const;
????int Find( LPCTSTR lpszSub ) const;
????int Find( TCHAR ch?? int nStart ) const;
????int Find( LPCTSTR lpszSub?? int nStart ) const;
?????????: ??????????? -1; ??????0 ???; nStar ???????????nStart ???????????? ??
?????????????????nStart???????????.
?????????
????CString s( "abcdef" );
????ASSERT( s.Find( 'c' ) == 2 );
????ASSERT( s.Find( "de" ) == 3 );
????Cstring str(“The stars are aligned”);
????Ing n = str.Find('e'??5);
????ASSERT(n == 12)
????24.CString::FindOneOf
????int FindOneOf( LPCTSTR lpszCharSet ) const;
?????????: ??????????? -1; ??????0 ???
???????::???????????е??????lpszCharSet?????????????????????????
?????????
????CString s( "abcdef" );
????ASSERT( s.FindOneOf( "xd" ) == 3 ); // 'd' is first match.
????25.CString::Format
????void Format( LPCTSTR lpszFormat?? ... );
????void Format( UINT nFormatID?? ... );
??????????lpszFormat ???????????????
????nFormatID ??????????
?????????
????CString str;
????Str.Format(“%d”??13);
???????Str?13
????26.CString::GetAt
????TCHAR GetAt( int nIndex ) const;
??????????????????nIndex????????????????????????????飬GetAt??????[].???nIndex???Χ?????????????е??????
????27.CString::GetBuffer
????LPTSTR GetBuffer( int nMinBufLength );
??????????????????????????????β??????????????LPTSTR ???
??????????nMinBufLength
???????????????????????????С?????????????????????β??????????
???????????????????????????CString ???????????????????????????LPTSTR ????const??????????????????CString ?????????????????GetBuffer ?????????????????????????????????????????CString ?????????????ReleaseBuffer ??????
?????????ReleaseBuffer ?????GetBuffer ????????????Ч????????????CString ???????????CString ???????????·??????????и???CString ???????????????????·???????CString ????????????仺??????潫?????????
????????????????????????????????????????β???????????????????ReleaseBuffer ??????????????????????????????????????????????β??????????????ReleaseBuffer ????????????-1 ??ReleaseBuffer ?????????????strlen ?????????????
?????????
????// CString::GetBuffer ????
????CString s( "abcd" );
????#ifdef _DEBUG
????afxDump << "CString s " << s << " ";
????#endif
????LPTSTR p = s.GetBuffer( 10 );
????strcpy( p?? "Hello" ); // ??????CString ????
????s.ReleaseBuffer( );
????#ifdef _DEBUG
????afxDump << "CString s " << s << " ";
????#endif
????28.CString::GetLength
????int GetLength( ) const;
?????????:??????????е?????????
???????:??????????????????CString ?????е????????????????????????β????????
???????????????????MBCS????GetLength ??????8 λ???????????????????????????е??????β????????????????
???????
????????????????????????CString::GetLength??
????// CString::GetLength ???
????CString s( "abcdef" );
????ASSERT( s.GetLength() == 6 );
????29.CString::Insert
????int Insert( int nIndex?? TCHAR ch );
????int Insert( int nIndex?? LPCTSTR pstr );
????????????????????????nIndex????????????????????????????????
?????????
????CString str( “HockeyBest”);
????int n = str.Insert( 6?? “is” );
????ASSERT( n == str.GetLength( ) );
????printf( “1: %s ”?? ( LPCTSTR ) str );
????n = str.Insert( 6?? ' ' );
????ASSERT( n == str.GetLength( ) );
????printf ( “2: %s ”?? (LPCTSTR) STR );
????n = str.Insert(555?? ‘1’);
????ASSERT( n == str.GetLength ( ) );
????printf ( “3: %s ”?? ( LPCTSTR ) str );
???????
????1. Hockeyis Best
????2. Hockey is Best
????3. Hockey is Best!