home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11678 < prev    next >
Encoding:
Internet Message Format  |  1992-07-26  |  1.7 KB

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