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

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

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

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!

 转自:

 http://blog.163.com/ccd_ok/blog/static/310238892007510113223798/

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