I am currently writing a program that replaces, deletes and inserts lines into a file. The program outputs line by line to the user and they can specify when they want to replace, delete or insert a line. I have the replace and delete functions completed but unsure how to approach the insertion.
Any help or hints to get me started would be greatly appreciated!
I actually solved it, this is what I came up with. I used a temp file to store the remainder of the code, wrote the user written line to the end of the original file and then rewrote the lines from temp file back to the original file (which was appended so it would write at the end and not overwrite existing lines).
However, I have a new question now. On line 21 I don't want it to reset back to the beginning of the original file, I want it to reset back to the line the user left off at (or maybe the newly inserted line). Is there a way to do this, to get the position of the line the user left off on?