Mail Archives: djgpp/1998/01/20/11:09:49
From: | Andy Maddison <maddison AT coventry DOT ac DOT uk>
|
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: | <Pine.OSF.3.91.980120101834.26833A-100000@leofric>
|
References: | <34c45b5b DOT 362910 AT news1 DOT c2i DOT net>
|
NNTP-Posting-Host: | leofric.coventry.ac.uk
|
Mime-Version: | 1.0
|
In-Reply-To: | <34c45b5b.362910@news1.c2i.net>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
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 <fstream.h>
> 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!
- Raw text -