Writting in a file (simple question...)

This is a discussion on Writting in a file (simple question...) within the C Programming forums, part of the General Programming Boards category; How can you write X character in a X position in a file without erasing the rest?
Like if you ...

Writting in a file (simple question...)

How can you write X character in a X position in a file without erasing the rest?
Like if you have a file
"Name:Tom and Jerry\n"
and you want
"Name: George and Jerry\n"
how it should be done effectively?

I believe fputc(), fwrite() overwrite existing data in the file so they are not useful. Like they would do:
"Name: GeorgedJerry\n"

No, you'll have to do it manually.
In this example, read "and Jerry\n" (everything after the "Name:Tom " part).
Calculate the difference of length "Name:George " - "Name:Tom " (which is 3 in this case).
Seek to "Name:Tom " + offset you calculated. Write the data you read.
The result should be something like:
"Name:Tom andand Jerry\n"
Now you'll have enough space to write overwrite "Name:Tom and" with "Name:George "