Mail Archives: djgpp/2000/08/26/14:01:21
On 24 Aug 2000, at 18:47, Tim 'Zastai' Van Holder wrote:
> "Rafał Maj" <r_maj AT poczta DOT onet DOT pl> wrote in message
> news:8o1930$36j$1 AT info DOT cyf-kr DOT edu DOT pl...
> > I think ther is bug in I/O binary mode :
> >
> > 1)
> > I can't open ofstream / ifstream in ios::binary mode.
> > When I use :
> > ifstream plik; plik.open("test.txt",ios::binary); plik<<"OK ;)";
> > plik.close();
> > then test.txt is empty. When I don't use ios::binary, then everything is
> OK.
> No, that means there's a bug in non-binary mode: You're using an input
> stream
> for output. Try using 'ofstream plik;' instead. You may also want to
> explicitly
> mention that you're doing output (ie use 'ios::binary | ios::out' as arg to
> open()).
'ofstream foo ("foo", ios::binary)' with gcc-2.95.2 is equivalent to
'fstream foo("foo", ios::binary)' so file will be opened for both input
and output. Currently one can use
ios::binary | ios::out
to workaround the problem.
As I said it's fixed in current CVS version of gcc-2.95 branch (ios::out
is added unconditionally, and similary ios::in for ifstream). I put this
patch in in my last build of gcc-2.95.2 in end of March. But binaries are
not uploaded to ftp.delorie.com. This will go in if gcc-2.95.3 will be
realesaed sometimes, but don't ask me when (and whether) it will
happen.
Andris
- Raw text -