i want to delete part of a binary file, let's say 12 byte record somewhere in the middle of the file.
i can think of only one thing:
- put the file pointer on the spot
- shuffle all the following records up

there're gotta be a better way ...
any suggestions ???

Load your file byte by byte into a vector of bytes and erase the elements you want. The vector will adjust itself.

>there're gotta be a better way ...
There isn't unless your system supports record-oriented files. Any solution will be a variation of what you were thinking of doing. Though naturally, any decent solution will take advantage of block reads and caching to avoid the performance hit of constantly reading and writing to disk.

vegaseat's suggestion is a good one for smaller files, but when working with multi-megabyte/gigabyte files, it's not practical to keep the entire file in memory at once. How you go about solving the problem depends on what files you expect and what kind of performance you're looking for.

This question has already been answered. Start a new discussion instead.