I'm having trouble adding to an exsisting line in a text file without overwriting that particular line or adding a new line.
for example, i have a line in my text file which is:
hello my name is
I would like to add to this line so it becomes:
hello my name is joe bloggs
<strong>i have a task to create a help desk program and i am trying to incorporate a feature that enables users to edit questions they have posted. as a result, the program will need to be able to append Any line within the text file - not necessarily just the last line</strong>Answer1:
If it's not at the end of the file, you're in trouble - you're basically talking about <em>inserting</em> data in the middle of a file, which isn't traditionally supported by file systems.
The normal way to approach this is to create a <em>new</em> file - copy the portion before the insertion point from the old file, then write your new data, then copy the remainder of the original file afterwards. Finally, do whatever renaming/deleting you need.