Insert VS Overwrite mode

Hello all!!
I have a little question.
I use the fprintf command to input some text to a file but when I use it it just works in Overwrite mode. I enter some text, then I need to go back (rewind) to insert another text earlier and it just erases the older text by writing the new one on it.
How can I just write a couple of lines, then go to the begining and insert anouther line?

Thanx in advance.
In advance, the usage of streams instead of the old C functions, that lack type safety and are only still available due to traditional reasons, is recommended. As far as your question is concerned, you need to know that access to a file happens sequentially. Thus it is easy to append text but prepending is not possible. However, I cannot think of a scenario that would unconditionally require that the text was prepended and not attached to the end.
So, depending on your environment (size of the file worked on, potentially yet a necessity to prepend etc.), you can either work around the problem by copying the old file (respectively loading it into your memory), writing into the newly created and finally appending the old one (from your memory), or you could just use append.
My prefered solution would be like this: http://nopaste.com/p/aVEfdNDUQ
Topic archived. No new replies allowed.