delete record from binary file in c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lehtf
    New Member
    • Jan 2013
    • 1

    delete record from binary file in c++

    How To Delete A Record From binary File - C++ ?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You have to know the format of the binary file. Otherwise you can do nothing.

    Then you create a new binary file and copy the old file to it up to where the delete starts then skip to where the delete ends and copy the rest of the file.

    Then copy the new file back on top of the old file and then delete the new file.

    Note that this is almost never done. Instead, you design a file system that has one character designated as a "deleted character" and then you can replace your deleted record with these deleted characters. This assumes all of the file handling recognizes this "deleted character" and ignores them.

    Comment

    Working...