From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP 2.01 C++ I/O problem Date: Tue, 23 Sep 1997 17:28:16 +0200 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 39 Message-ID: <3427E010.CE0E9FCD@LSTM.Ruhr-UNI-Bochum.De> References: <199709220855 DOT SAA00358 AT rabble DOT uow DOT edu DOT au> NNTP-Posting-Host: c64.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 * *************************************************************