pangelll
asked on
Overwriting a record in a binary file
Hi, here I am trying to overwrite a record in a binary file, however it overwrites the entire file with the write function. I have attempted to use ios::trunc in the fstream constructor, but still produces same result.
*in this example code i'm simply trying to overwrite the first record, I can retrieve this.
*in this example code i'm simply trying to overwrite the first record, I can retrieve this.
fstream f("records.bin", ios::binary | ios::out);
f.seekp(0);
f.write(reinterpret_cast<const char*>(&binPerson),sizeof(binPerson));
f.close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER