string_replace?

Is there a substr_replace in c++ like the one in php?

like it would replace all substr s with newstr?

Thanks!
Not exactly, there is a replace() method and a find() method which should allow you to do what you are asking though.
How would that work? Could you possible show me a function?
http://cplusplus.com/reference/string/string/find_first_of.html
http://cplusplus.com/reference/string/string/find.html
http://cplusplus.com/reference/string/string/replace.html

You need to use some combination of find and replace, rather than substr. Use find_first_of to find the first occurrence and remember the pos returned. You can do this in a lot of ways. You can than use find in a while loop to find the remaining occurrences of the substring within the object. I could try to write an example but I don't know what type of beast you are dealing with. It is better if you read the examples on this site. Every member function is documented with explanations. I'm just giving you the member functions that I know will help you with this problem. There should be enough in those links to help you solve your problem.

Remember you know the size of the substring you are searching for so after each find use that information to advance the position prior to the next find operation. You can replace as you go or simply remember the positions where the sub strings are found and replace them after you finish searching.
I am using the win api ini reading functions, i want to turn all ~ into a newline.
Topic archived. No new replies allowed.