brgdotnet
asked on
File parse code to search and replace a string of text.
I am looking for some C or C++ code that would parse a text file, and replace all occurrences of a string with another string.
So if I have a text file with this text : Mary had a little lamb who's name was Mary Anne.
And I want to replace "Mary" with "Terry", how can I do that in C++. My file might have up to 1000 lines of text in it. The end result would be Terry had a little lamb who's name was Terry Anne.
So if I have a text file with this text : Mary had a little lamb who's name was Mary Anne.
And I want to replace "Mary" with "Terry", how can I do that in C++. My file might have up to 1000 lines of text in it. The end result would be Terry had a little lamb who's name was Terry Anne.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note that the while loop would not be equivalent to the for loop if you wanted to replace "Mary" with "Mary, Mary, Quite Contrary"