What file I/O class has a replace() method?
If the program deletes the file BEFORE calling the declare() method, then appending to a new file would work.
Type: Posts; User: Norm
What file I/O class has a replace() method?
If the program deletes the file BEFORE calling the declare() method, then appending to a new file would work.
I guess there are things done in other parts of the program that have not been explained. The posted code appends what it writes to the file. It does not replace the contents of the file.
What is in the file if you execute the program more than one time?
What's in s and what is in newTxt?
If s is all of the old file's contents and newTxt is "int"
how does writing those two values one after the other solve your problem?
What about my second and third questions?
I don't think the posted code does anything like what you want:
Where does the currently posted code read the contents of the file?
Where does the posted code change anything that could have been...
What happens when the posted code is executed? Can you post something that shows what it does and add some explanations that say what is wrong and show what you want the output to be.