|
-
May 31st, 2008, 08:36 AM
#2
Re: How to read a file char by char and replace it with string????
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.
- Alon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|