delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/09/06/02:45:39

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.131.211
From: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: file I/O
Organization: Systematic Software
Message-ID: <qt0oj0tr85nvnhkl9sp5s27tee45a1ukre@4ax.com>
References: <20040904180941 DOT 51563 DOT qmail AT web20223 DOT mail DOT yahoo DOT com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 31
Date: Mon, 06 Sep 2004 06:34:32 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw1no 1094452472 24.71.223.147 (Mon, 06 Sep 2004 00:34:32 MDT)
NNTP-Posting-Date: Mon, 06 Sep 2004 00:34:32 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 4 Sep 2004 11:09:41 -0700 (PDT) in comp.os.msdos.djgpp,
pradyut bhattacharya <pradyut100 AT yahoo DOT com> wrote:

>i have written on object I/O
>
>the code : -
>
>----------------------------------------------------------------------------------------------
>#include <fstream>
>#include <iostream>
>
>using namespace std;

>int main()
>{
>	ofstream Sfil("studfile.dat");

You're creating a new file each time the program runs; you might want
to try using:
	fstream Sfil("studfile.dat", 
		ios::in | ios::out | ios::app | ios::nocreate);
and if it throws an exception, retry with:
	fstream Sfil("studfile.dat", 
		ios::in | ios::out | ios::app | ios::noreplace);
or vice versa. 

-- 
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
    fake address		use address above to reply

- Raw text -


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