string str = "one three";
string::iterator it;
string add = "two ";
Lets say I want to add: “two ” right after the space in “one”.
the space would be str[3] correct? so: in this case, n = 3;
for (it=str.begin(); it < str.end(); it++,i++)
{
if(i == n)
{
// insert string add at current position
break;
} // if at correct position
} // for
*it would allow me to access the character at str[3], but I don’t know how I would add in the string from there. Any help is appreciated, thanks. If anything is confusing or unclear please let me know
You can make use of the
insertmethod of the string class.