Message-ID: <318928C7.32B2@public1.guangzhou.gd.cn> Date: Fri, 03 May 1996 06:27:35 +0900 From: Wang TianXing Organization: No Organization MIME-Version: 1.0 To: nate CC: djgpp AT delorie DOT com Subject: Re: gxx bug? binary files References: <4m6lik$h8g AT misery DOT millcomm DOT com> Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit nate wrote: > > The example program at the end of this message is a generic > example of binary file creation, reading writing and modification with > an fstream declared with ios::bin or ios::binary (depending on the > compiler). All of the compilers produced the expected result with the > exception of DJGPP. Anyone have any ideas why? Example program > execution and source code is printed at the end of this message. > [snip] > //modify temp_person (make it 66) and write it back to object 50 in file > temp_file.open(FILE_NAME, ios::in|ios::out|ios::binary|ios::nocreate); Change that line to: temp_file.open(FILE_NAME, ios::in|ios::out|ios::app|ios::binary); libg++ 2.7.1 truncates the file when it sees 'out' without 'app'. And, 'nocreate' is neither a standard thing nor a promise that the file will not be truncated. --- Wang TianXing