Mar 22, 2009 at 9:21pm UTC
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
Mar 22, 2009 at 9:32pm UTC
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.
Mar 23, 2009 at 7:03pm UTC
Where can i know more about "STL string" ?
Mar 23, 2009 at 7:55pm UTC
The reference section of this site is a good place to start.
Mar 24, 2009 at 5:17am UTC
STL find replace algo is not the best so you can implement KMP algo which will be better. google kmp search.