I'm copying over text from one file to another, with certain changes.
I have input.txt, tmp.txt and output.txt.
The idea is to copy a few lines over to tmp.txt (until we reach a delimiter), move the text from tmp.txt to output.txt, wipe tmp.txt and then continue the cycle until we reach the end of input.txt.
I'm having trouble with the tmp.txt file. After the first time I copy the contents over it stops accepting new text, even after I've closed, deleted and re-opened the file for writing. My code has become really messy.
Could anyone suggest a neat way of doing this? (coping to tmp.txt, copying from tmp.txt,wiping tmp.txt continuing the cycle)
Thanks in advance.
N.b. This is a subtask that I'm stuck on with a homework problem- I'm removing c++ comments from a text file.
Edit: For anyone wondering why I need the tmp.txt: If the program encounters */ (close comment) without an open comment then it will need to treat everything before it, until the previous comment, as a a comment. I'm using the temp to hold text that may or may not be a comment. If it is- I'll delete the text in tmp, if not, I'll copy the text in tmp to output.txt.