I have a binary file, and I need to delete a specific number of characters
in it.
The file contains records, each record has a specific length.
So the way I wanna handle deleting is that I will overwrite the record I
want to delete with the last record in the file, then actually delete that
last record in the file. the problem Im having is how to delete that last
record in the file.
Suppose each record is of length 43, then I have something like:
fstream inoutData;
inoutData.open("this_file.txt", ios::binary | ios::in | ios::out);
char read_this[44];
inoutData.seekg(-43,ios::end);
inoutData.read(read_this,43);
read_this[43] = '\0'; // now read_this contains the last record
inoutData.seekp(-43,ios::end);
inoutData.write("",43); // << here, how I can delete the last record???