From: Andy Maddison Newsgroups: comp.os.msdos.djgpp Subject: Re: Bug in djgpp c++ compilation?? (or am I just knocking my head against the wrong wall?) Date: Tue, 20 Jan 1998 10:23:26 +0000 Organization: Coventry University Lines: 33 Message-ID: References: <34c45b5b DOT 362910 AT news1 DOT c2i DOT net> NNTP-Posting-Host: leofric.coventry.ac.uk Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <34c45b5b.362910@news1.c2i.net> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Tue, 20 Jan 1998, Kim Robert Blix wrote: > > Any idea why this wont work with djgpp? Its written word by word from > a C++ book, so I dont think its my fault :) .. (the operative word > there is think). I've had similar problems with more or less all C++ > file rutines. Any help ? > > --cut-code-- > #include > int main() > { > ofstream OutFile; > int MyNumber = 3; > > OutFile.open("testfil.dat",ios::binary); > OutFile.write((char *)&MyNumber,sizeof(MyNumber)); > OutFile.close(); > > return 0; > } > --end-code-- > I posted a similar query a while back and discovered where I was going wrong. Someone (sorry, I forgot your name) recommended that I try the following: OutFile.open("testfil.dat",ios::binary|ios::out); Specifying ios::out/in seems to work for me!