Why not create a second vector/string a push_back each character of the morse code? You could even write an algorithm that takes two input iterators and an output iterator, and pass it a back_insert_iterator for a string or vector as the output iterator.

To replace a character with several characters in-place in a vector, you'd need to use vector::insert and take care that the original characters are removed from the vector, bearing in mind that frequent insertion/removal from the middle of a vector is not considered ideal. To do this with a string, you could simply use string::replace.

Hopefully that's all clear, but since you haven't provided the code for your attempt so far, I won't provide any either.