Mail Archives: djgpp/1996/05/02/18:56:05
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
- Raw text -