如果nIndex 大于了原对象的长度,该函数就将ch或者pstr连接到原函数的最后面。 Example实例 //The following example demonstrates the use of CString::Insert. CString str(“HockeyBest”); int n = str.Insert(6, “is “); ASSERT(n == str.Ge
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\n”, (...
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...
//当nCount为负数时,函数没有任何操作。 int Insert( int nIndex, TCHAR ch ) int Insert( int nIndex, LPCTSTR pstr ) 在下标为nIndex的位置,插入字符或字符串。返回插入后对象的长度 例:csStr="abc"; csStr.Insert(2,'x'); cout<<csStr; //abxc csStr="abc"; csStr.Insert(2,"xyz"); cou...
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( ) ); ...
string::capacity–返回当前的字符存储容量 string::shrink_to_fit(C++11新增)–降低内存容量到刚好 修改器 string::clear–清空内容 string::insert–插入字符或字符串。目标 string 中的插入位置可用整数值或迭代器表示。如果参数仅为一个迭代器,则在其所指位置插入0值。 string::erase–删除 1 个或 1 段字符...
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( ) ); ...
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” ); ...
//当nCount为负数时,函数没有任何操作。 int Insert( int nIndex, TCHAR ch ) int Insert( int nIndex, LPCTSTR pstr ) 在下标为nIndex的位置,插入字符或字符串。返回插入后对象的长度 例:csStr="abc"; csStr.Insert(2,'x'); cout<<csStr;//abxc ...
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\n”, ...