I was developing a small test application using Random Access File. I am attaching the source code with it. I want to delete a record from the file. I have searched similar threads
on Delete Record Random Access File. These threads suggest setting a flag as deleted against a record and not display it. I want to actually delete it. I tried to search the record and
tried to append a null record to that file pointer position. Nothing happens. Please suggest, whats the correct way to do it? Please find the source code below.
Here is the code for my main program where different operations are present.
Please suggest the correct way, in order to delete a record from a particular location in Random Access File?
It means, every time, i delete the record, i need to write it to a new file. What if we try to insert a blank record at that position?
Will that do? Please have a look at my code, i am trying to write a blank record, but it doesn't show any effect.
Back in the early stone age of computing, when random-access files were the hottest technology, we solved this problem by requiring each record to have a "deleted" flag as one of their fields. Just as your research suggested, in fact. Then deleting a record was as simple as setting the "deleted" flag to some particular code indicating the record was deleted.
That's because a random-access file consists of an array of bytes on a disk. You can't delete a byte from an array any more than you can delete the number 12 from the integers.