I am using this code to replace a letter in a string it works fine but it removes the first letter that i need to keep. I only need a * in the centre of the string but this problem has stumped me.
textWords[i].replace(pos, 2 , 1 , '*');
All the words i am replace the middle character in are three characters long and it always get rid of the first character as well. The replace function is the one used for vectors i did not write it and pos is defined by the code below.
size_t pos = textWords[i].find(bannedWords[j]);
Any help is appreciated.
if (pos != npos) textWords[i][pos + 1] = '*';??