Mail Archives: djgpp/2000/01/19/14:31:59
In article <2 DOT 07b5 DOT 3MYIJ DOT FOJEW0 AT pauzner DOT mccme DOT ru>, djgpp AT delorie DOT com wrote:
>I run into the following problem:
>
>using DJGPP 2.02-2.03 and GCC/GPP 2.81 or 2.95.1
>on a plain i386/DOS 6.22 machine
>I can not open fstream in BINARY mode,
>e.g. I got zero size file from the sample program below.
>
>If this is G++ problem could you forward this message to
>GCC/G++ mailing list, please.
>
It's not a compiler problem. Just something that newbie C++ users frequently
run into:
>It is OK when I use FILE *fp; fp = open(somename, "wb");
>though.
>
> ofstream fpw (argv[1], ios::binary);
In C you say "wb" for write binary. The C++ analogon is ios::binary|ios::out.
So if you change that line to
ofstream fpw (argv[1], ios::binary|ios::out);
you will be fine.
--
Manni
- Raw text -