Q:

How to insert text into a file using fseek and fwrite

How to make fseek not overwrite what was at the given position when used with fwrite?
I am opening a file with 
file = fopen(filename, "r+");

and then use
fseek (file, pos, SEEK_SET);

to go to the position I need, using
fwrite(text, 1, text_size, file);

to write the data.
example:
Say, I want to add '7' at position 3:
abcdef

I want this to be
abc7def

A:

You can't insert into a file. The only way to accomplish that would be saving the rest of the file somewhere, write your new stuff, then append the rest of the file from where you've saved it. But you have to re-write the whole part of your file after what you want to insert.

