Let me get right to the point.
I have a file that has alot of information in it. I want to change one line of that file and leave the rest alone. Here is how I have been doing it.
1) I open the file.
2) I load the whole file into a string (C++ String)
3) I search the string for a certain piece of text and get the index.
4) I use the string's replace methon to put my new string in place of the old string
Here is the problem.
The text I put into the file varies in size, anywhere from 16-27 charaters in length. What happens is the string ends up overwriting the begining of the next line. Unless I imagined it, it was working until I did a final test on it. Is there a better way to search a file and replace just one line of text?



LinkBack URL
About LinkBacks


