|
A few comments:
- You should probably close fin before opening fout, so that there is no problems with the file being open for reading and writing at the same time
- You are only writing 10 integers (40 bytes) into the file - this won't wipe out any data after that. Find out the size of the file first and write that many bytes back over it
- I am not sure if using ofstream to open the file will cause it to be truncated on the spot, which would mean that the location of all the file's data on the disk may be wiped out and given back to the operating system. This means that when you try to write over the data, you might be writing to a different (free) part of the disk all together. Find a method of opening the file that doesn't truncate it.
|