Mail Archives: djgpp/1997/11/27/02:15:52
> Can anyone help me?
>
> Program Fragment:
>
> unsigned char palette[768];
> fstream inFile;
> inFile.open("pal.dat",ios::binary);
> inFile.seekg(0); //not essential
> inFile.read(palette,768);
> inFile.close();
>
> This works fine using Borland C++, but under DJGPP the array (palette) is
> always filled with zeros (NULLs?).
> What is happening? Why doesn't it work?
> I like using C++ and I don't want to have to switch to C style file i/o.
>
Looks like you stumbled over a damn bug in libiostream.
It opens the file in write mode, thus truncating it to length 0.
The workaround is to say something like
int fd = open("pal.dat",O_RDWR|O_BINARY);
infile.open(fd);
Some comments on this bug:
I have answered this by now at least 3 times in the last two months,
does this qualify for a FAQ ;-)
Seriously: Who ported libiostream to DJGPP? Not to blame him/her, just
to get an idea how much work that is.
And, anybody working on that?
Ciao
Tom
******************************************************************
* Thomas Demmer * Phone : +49 234 700 6434 *
* Universitaetsstr. 150 * Fax : +49 234 709 4162 *
* Lehrstuhl fuer Stroemungsmechanik * *
* D-44780 Bochum * *
******************************************************************
* Email: demmer AT LStM DOT Ruhr-Uni-Bochum DOT De *
* WWW: http://www.lstm.ruhr-uni-bochum.de/~demmer *
******************************************************************
The amount of intelligence on this planet is constant.
The population is increasing.
- Raw text -