home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!contessa!mwm
- From: mwm@contessa.palo-alto.ca.us (Mike Meyer)
- Subject: Re: SAS/C 5.10b fopen(...,"w+") bug?
- Newsgroups: comp.sys.amiga.programmer
- Distribution: comp
- References: <1992Jul26.190553.26493@wam.umd.edu> <1992Jul27.012709.11726@wam.umd.edu>
- X-NewsSoftware: Amiga Yarn 2.0, 1992/06/25 01:41:36
- Keywords:
- Summary:
- Message-ID: <mwm.1bc9@contessa.palo-alto.ca.us>
- Date: 26 Jul 92 23:51:33 PST
- Organization: Missionaria Phonibalonica
- Lines: 31
-
- In <1992Jul27.012709.11726@wam.umd.edu>, walrus@wam.umd.edu (Udo K Schuermann) wrote:
- > In article <1992Jul26.190553.26493@wam.umd.edu> I wrote:
- > > struct FILE *myFile;
- > > myFile = fopen("t:test","w+");
- > >
- > >This clears out the file if it contains any information instead of preserving
- > >existing information! The documentation on page L72-L73 describes the use of
- > >the "w+" mode as 1) creating the file if it doesn't exist yet, 2) preserving
- > >existing contents (WHICH IT DOESN'T!), 3) providing r/w access to the file.
- >
- > Well, this went quickly! Looks like it IS a bug. The following code is a
- > workaround which seems to provide equivalent file access:
- >
- > FILE *myFile;
- >
- > if( (myFile = fopen("test.file","a+") ) {
- > fclose( myFile );
- > myFile = fopen("test.file","r+");
- > }
- >
- > Thanks to Trent Gray-Donald <tagraydo@undergrad.math.waterloo.edu> for
- > responding so quickly and confirming the problem was not my own stupidity.
-
- This could be a bug I found earlier, in when someone else asked about
- it. The "a" modes fail if the first thing you do is "fputs" instead of
- an "fprintf". I suspect the old portable IO calls aren't correctly
- checking the mode on the file, or some such. Then again, "a+" could
- behave differently than "a".
-
- <mike
-
-