I am using file pointers to add some content to an XML file. The problem is that writing contents seem to be overwriting the other text. For example, my file has the following content:
Hello every, this is C.
I want to insert body in the text so the content looks like this:
Hello every body, this is C.
For this, I fseek my pointer beyond 'y' in 'every,' and add ' body', which ends up writing the file content like this:
Hello every, body is C.
This actually overwrites word 'this'. How can I do this using file pointer without overwriting file content?
I can think of writing content to a diff file, deleting original file and renaming that file later to original file to accomplish this.
Is there any other way of inserting word in file ?