Mail Archives: djgpp/1998/07/30/04:45:30
Jamie Love (jamie DOT love AT clear DOT net DOT nz) wrote:
> Well, because this problem is really annoying, I thought I would create
> a basic program to test my file handling. Coding the file was ok, with
> no warnings on compilation (command line: gxx -Wall -o tst.exe tst.cc)
> but when I run it, I comes up with error writing to file on the first
> integer. The question is, does anyone know why? The file (test.dat) is
> created with length 0 also. Also, if I have mucked up my code then
> please tell me as as far as I can make out, this should work!
>
> I use:
> bnu281
> djdev201
> gpp281/lgp281
> lgpp280
You are mixing lgpp280 and lgpp281??? This could give any problem you
like;-) with gcc281 use gpp281 and lgp2811.
There was a major change in the c++ library from 280 to 281, IIRC
> int main() {
> ofstream infle("test.dat", ios::bin | ios::trunc);
I think you should use: ios::bin | ios:trunc | ios::out
you overwrite the default mode (ios::out) with what you give it, so
include it to retain it.
> ifstream outfle;
> if(!writeInts(infle)) {
> cout << "\nError writing to file";
> return 0;
> }
> infle.close();
> outfle.open("test.dat", ios::bin);
I think you should use: ios::bin | ios::in, but you never get to that,
do you?
And by the way, a strange way to name your files:
infle == the output file.
outfle == the file you read from.
> Also, could you please cc this to my email, if possible, thanks
I have, and you're welcome,
Robert.
--
rjvdboon AT cs DOT vu DOT nl | "En dat is niet waar!" sprak (ex?) Staatsecre-
www.cs.vu.nl/~rjvdboon | taris Netelenbos (onderwijs) fel.
- Raw text -