Deleting a File record

HI

i want to delete some records from a binary file without creating a new file.
please suggest me some way to do it as i m new to file handling.
Thanks in advance.

Shubham
That depends entirely upon the kind of binary file it is (that is, what format specification it has), and the size of the file.

For example, if you are modifying a GIF file, you could do it easily by having enough working memory for no more than the size of the block you are deleting.

Let us know the details.
I am using .dat file
and i have just started doing file handling so no of records are very less for about 20-25
I strongly advise you to use a dedicated library for this task, such as sqlite.
Step 1: Read file into memory.

Step 2: Find and destroy desired data.

Step 3: Adjust other data fields if needed.

Step 4: Overwrite old file with adjusted data.

Although it is one of the larger header files, it has close to everything you would need for this task: http://www.cplusplus.com/reference/iostream/ The rest of it can be found in the STL though, there is no need for a 3rd party lib in order to modify a data file unless you need to translate or decode the data.
Topic archived. No new replies allowed.