I have a program that optionally allows the user to overwrite the input file (binary) with the output file (text).
When I detect the output file is the same name as the input file, I create a temporary file, via tempnam(NULL), and write the output to it.
When finished writing, I close both the input file and output file, and then look to see if the original input file needs to be overlaid with the output file. If it does, I open the output file in ios::in mode and the input file in ios:ut mode and simply copy it over via in.read and out.write.
However, every time I end up with zero bytes read, and thus zero written. When I do not go through the overlay process, the output file is fine and has the data it is supposed to. When I do go through the overlay process, my counters from the primary process tell me the same amount of data was written. I have verified the output file does contains data from the primary operation.
Does anything in this process sound suspect?