Possible Duplicate:
C++: How do I replace all instances of of a string with another string?
Imagine you have a string: This is a string and this is the same string too
and you want to replace every string
word in the... well, in the string, and change it to chain
in order to obtain: This is a chain and this is the same chain too
.
The problem is that the function std::replace()
only work nice if it changes one character for another (imagine... replace all e
for i
).
I found several solutions for that but all of them included other libraries or weird whiles (which I really don't understand).
What I want is an elegant solution for that using replace because I'm working in a project that times are everything.