Reputation: 37
I've been messing around with binary files the last whole week. One thing I can't figure out how to do is selectively delete a record from the binary file. Is this possible in c++? If not, what are ways in which you can do this.
I'm contemplating, maybe creating a duplicate file without the record inside, but that would seem rather inefficient for very large data files. Any more efficient ways, or any way of duplicating a file efficiently? I''m surprised there's ways to delete files, but not selectively delete from a file.
Upvotes: 0
Views: 986
Reputation: 14688
Just make sure ever record have a flag "deleted" which you set to false when you first write the record, but then change to true if you want to mark the record deleted.
Upvotes: 0
Reputation: 206607
Unlike data structures in memory, you can't pull out a record from a file. You have to:
Upvotes: 4