delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/19/14:31:59

Newsgroups: comp.os.msdos.djgpp
From: manni DOT heumann AT gmx DOT de (Manni Heumann)
Subject: Re: DJGPP/GPP: can not open C++ [io]fstream in binary mode
References: <2 DOT 07b4 DOT PZ9S DOT FJ8E10 AT pauzner DOT mccme DOT ru> <AAr5cRsqg9 AT pauzner DOT mccme DOT ru> <2 DOT 07b5 DOT 3MYIJ DOT FOJEW0 AT pauzner DOT mccme DOT ru>
X-Newsreader: News Xpress 2.01
Date: Wed, 19 Jan 2000 09:00:12 GMT
NNTP-Posting-Host: dhcp33-226.uni-bielefeld.de
Message-ID: <38857d22$1@news.uni-bielefeld.de>
X-Trace: 19 Jan 2000 10:00:18 +0200, dhcp33-226.uni-bielefeld.de
Lines: 32
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019