Insert
This overloaded member function inserts a char or substring at the given index within the string.
int Insert( int nIndex, char ch )
int Insert( int nIndex, LPCTSTR pstr )
The length of the changed string.
EX1
//Insert a character void string_Insert_ex1() { string str(" love summer"); str.Insert(0,'I'); printf("After insertion: the string is \"%s\".\n", str); //After insertion: the string is "I love summer". }
EX2
//Insert a string void string_Insert_ex2() { string str("I summer"); str.Insert(2,"love "); printf("After insertion: the string is \"%s\".\n", str); //After insertion: the string is "I love summer". }
This overloaded member function inserts a substring at the given index within the string. The nIndex parameter identifies the first character that will be moved to make room for the substring. If nIndex is zero, the insertion will occur before the entire string. If nIndex is higher than the length of the string, the function will concatenate the string and the substring.
string::Delete
origin.h