How to implement some find and replace function

I've spending some on my time on this issue but unfortunately I couldn't completed what I'm trying to achieve.

My objective is to implement this kind of function.

char * findandreplace(char *originalstr, char *str1, char *str2) // maybe strings size as arguments too ?

In which the function would replace any ocurrence of str1 in originalstr for str2, any thoughts on this?

Thanks in advance,
Zé Alberto
STL string has the replace method. You just need to do it in a loop.
The bare string manipulations are complex if, for example, the length of
str2 is not exactly equal to the length of str1.
Where can i know more about "STL string" ?
The reference section of this site is a good place to start.
STL find replace algo is not the best so you can implement KMP algo which will be better. google kmp search.
Topic archived. No new replies allowed.