home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11667 < prev    next >
Encoding:
Text File  |  1992-07-26  |  1.7 KB  |  42 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!haven.umd.edu!wam.umd.edu!walrus
  3. From: walrus@wam.umd.edu (Udo K Schuermann)
  4. Subject: Re: SAS/C 5.10b fopen(...,"w+") bug?
  5. Message-ID: <1992Jul27.012709.11726@wam.umd.edu>
  6. Summary: workaround for library bug in fopen() with SAS/C 5.10b
  7. Sender: usenet@wam.umd.edu (USENET News system)
  8. Nntp-Posting-Host: wam.umd.edu
  9. Organization: University of Maryland, College Park
  10. References: <1992Jul26.190553.26493@wam.umd.edu>
  11. Distribution: comp
  12. Date: Mon, 27 Jul 1992 01:27:09 GMT
  13. Lines: 27
  14.  
  15. In article <1992Jul26.190553.26493@wam.umd.edu> I wrote:
  16. >    struct FILE *myFile;
  17. >    myFile = fopen("t:test","w+");
  18. >
  19. >This clears out the file if it contains any information instead of preserving
  20. >existing information!  The documentation on page L72-L73 describes the use of
  21. >the "w+" mode as 1) creating the file if it doesn't exist yet, 2) preserving
  22. >existing contents (WHICH IT DOESN'T!), 3) providing r/w access to the file.
  23.  
  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.  
  27.      FILE *myFile;
  28.  
  29.      if( (myFile = fopen("test.file","a+") ) {
  30.        fclose( myFile );
  31.        myFile = fopen("test.file","r+");
  32.      }
  33.  
  34. Thanks to Trent Gray-Donald <tagraydo@undergrad.math.waterloo.edu> for
  35. responding so quickly and confirming the problem was not my own stupidity.
  36.  
  37. I seem to have a knack for hunting down O/S and compiler/library bugs ... :-/
  38.  
  39.  ._.  Udo Schuermann     "If I went around calling myself emperor just because
  40.  ( )  walrus@wam.umd.edu  some moistened bint lobbed a scimitar at me, they'd
  41.  Seeking virtual memory   put me away!"         -- Monty Python's "Holy Grail"
  42.