CString::Insert

int Insert( int nIndex, TCHAR ch );
  throw( CMemoryException );
int Insert( int nIndex, LPCTSTR pstr );
  throw( CMemoryException );

返回值:返回被改变的字符串的长度。

参数:
nIndex某个字符的索引,在这个字符的前面将要进行插入操作。
ch要插入的字符。
pstr一个指向要被插入的子字符串的指针。

说明:
此成员函数用来在字符串中的给定索引处插入一个单个字符或一个子字符串。
nIndex参数标识了将要被移走以给字符或子串空间的第一个字符。如果nIndex是零,则插入将方式在这个字符串之前。如果nIndex大于字符串的长度,则函数将把当前的字符串与由ch或pstr指定的新字符串连接起来。

示例:
// 下面的例子说明了如何使用CString::Insert。
CString str("HockeyBest");
int n = str.Insert( 6, "is" );
ASSERT( n == str.GetLength( ) );
printf( "1: %s\n", ( LPCTSTR ) str );
n = str.Insert( 6, ' ' );
ASSERT( n == str.GetLength( ) );
printf ( *2: %s\n*, (LPCTSTR) STR );
n = str.Insert(555,'1');
ASSERT( n == str.GetLength ( ) );
printf ( "3: %s\n", ( LPCTSTR ) str );
// 上面的代码将产生下面这些输出行:
1.Hockeyis Best
2.Hockey is Best
3.Hockey is Best!

请参阅:CString::Delete, CString::operator +