www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/12/02:58:34

Date: Wed, 12 Aug 1998 09:55:00 +0200 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
To: Endlisnis <s257m AT unb DOT ca>
cc: djgpp AT delorie DOT com
Subject: Re: fstream.open??
In-Reply-To: <35D0B724.CBFBEFC9@unb.ca>
Message-ID: <Pine.A32.3.91.980812095213.35246B-100000@ieva01.lanet.lv>
MIME-Version: 1.0


On Tue, 11 Aug 1998, Endlisnis wrote:

> Peter Danielsson wrote:
> 
> > I want to change the first byte in a file using fstream. If i use
> > fil.open then fil.write(&ch,1) then fil.close() I get a 1byte large file
> > only including ch. What can I do??
> >
> > /Peter

It's known problem with lgpp272b.zip (more exactly with libstdc++-2.7.2).
This problem is no more with C++ library for gcc-2.8.1. So consider 
upgrading gcc and libstdc++.

> 
> Try this:
> fstream File(Filename, ios::app);
> File.seekp(0,ios::beg);
> File.write("a",1);
> File.close();
> 

This will not help. fstream::fstream erorrously truncates the file.

> 
> I think there is a way to open a file so that it starts at 0 but is not
> truncated, but I don't know how.  There is a enum for it "ios::trunc" but
> that seems to be the default, I wonder how you can unset that?
> 

- Raw text -


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