posted 20 years ago
The usual first question ... is this homework? Guessing it is, I'll hint at some things to look at rather than toss out code.
You can use random access files for this kind of thing if you have fixed length records. So it's good for storing identical structures, but not appropriate for handling plain text files with lines of different length.
With that in mind, let's think about 10-byte records.
What is the starting byte for record "n"? Files start at byte zero, so it's something like (n-1)*10. Try a few different record numbers and see if the starting bytes (offsets) look right.
How do we read record 5? Compute the starting byte and read a record length worth of bytes.
How do we update record 5? Go to the same starting byte and overwrite what's there.
Think about Insert and Delete some more. What would have to happen to the records after the one you insert or delete?
You're more than welcome to start coding some of this and post your code in progress if you run into trouble. Hope that helped!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi