Mail Archives: djgpp/1997/09/23/18:00:52
Brett Porter wrote:
>
> > - fails if using C++ style in DJGPP
> > ifstream f("test.txt", ios::nocreate | ios::in | ios::out | ios::binary);
> First of all, it should be fstream, not ifstream. ifstreams can't write data.
> Ahh, but I see you had it correct in your code anyway. You should also
> specify ios::ate, ios::noreplace or ios::nocreate to make sure it is not
> overwritten (you need this in Borland too, I'm positive).
>
> However, this is a bug in GCC I believe (I had the same problem some time
> back). Random file access does not work in iostreams. I didn't get any
> answer about fixing it other than getting the source and recompiling GCC.
> The only option I have found is to use the old C FILE streams (I actually
> like these better for binary anyway).
It is in the iostream library, to be precise. As a fix you may do
int h = open("test.txt" , O_RDRW|O_BINARY); // fingers crossed, check
info
if( h<0)
bail_out
fstream f(h); // Init fstream with a valid file handle
Ugly, but it works. Somewhere I saw a replacement for djgpp's,
but I don't remember where. It was related to TurboVision.
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -