ca******@yahoo.com wrote:
I have worked with C++ off and on, but I am not sure how this must be
done. I need to modify some of the text in certain files. Specifically
I need to search for a certain word, and modify that word i.e. Change
it to some other shorter word.
I dont think that I can declare a buffer, because it may happen that
these files may be too big.
I hope someone has some ideas how this might be done.
The usual approach to this is to open your file for reading, open another
file for writing, start copying until you encounter the string you need
replaced, read the original, write the replacement, then proceed with your
copying until the source file is all copied. Then upon successful closing
of both files, rename (or delete) the original and rename the temporary
file so that it has the name of the original before the operation.
Nothing language specific in all this.
V