X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Trace-PostClient-IP: 68.147.131.211 From: Brian Inglis Newsgroups: comp.os.msdos.djgpp Subject: Re: file I/O Organization: Systematic Software Message-ID: 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 wrote: >i have written on object I/O > >the code : - > >---------------------------------------------------------------------------------------------- >#include >#include > >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