Updating a File

Hello,

I was trying to update the data in a file for a dbms. Anyway, at some point, I had to change some content, say number of users, without changing anything else.For example,


3
Mary Jenny


Updated version is the following

4
Mary Jenny



Since my files will be much bigger, copying the unchanged data to another file will be time consuming. Is there any other way -besides copying it- to change just a piece of data but not anything else. Thanks in advance.
Read the file to memory, modify, write back.
If the files are too big to fit in memory, perhaps you should use a database. Raw files are not the best when it comes to modifying content in the middle. For your example, if you just overwrite bytes, your file at some point may end up looking like this:
10Mary Jenny
or
100ary Jenny
Topic archived. No new replies allowed.