www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/02/18:56:05

Message-ID: <318928C7.32B2@public1.guangzhou.gd.cn>
Date: Fri, 03 May 1996 06:27:35 +0900
From: Wang TianXing <gztxwang AT public1 DOT guangzhou DOT gd DOT cn>
Organization: No Organization
MIME-Version: 1.0
To: nate <nate AT millcomm DOT com>
CC: djgpp AT delorie DOT com
Subject: Re: gxx bug? binary files
References: <4m6lik$h8g AT misery DOT millcomm DOT com>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019