home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!wupost!psuvax1!psuvm!tew105
- Organization: Penn State University
- Date: Wed, 29 Jul 1992 12:51:58 EDT
- From: <TEW105@psuvm.psu.edu>
- Message-ID: <92211.125159TEW105@psuvm.psu.edu>
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: SAS/C 5.10b fopen(...,"w+") bug?
- Distribution: comp
- References: <1992Jul26.190553.26493@wam.umd.edu>
- Lines: 34
-
- In article <1992Jul26.190553.26493@wam.umd.edu>, walrus@wam.umd.edu (Udo K
- Schuermann) says:
- >I use SAS/C 5.10b under KS2.04 and am opening a file with a statement such
- >as the following:
- >
- > 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.
- >
- >The function behaves exactly as if I had not specified the "+" symbol in the
- >mode. I have though. I have I have I have! :-/
- >
- It should behave exactly as if you opened it without the + except now you can
- preform reads and writes to the file (after a fseek). It sounds like you want
- to use a different mode, either r or a. Lets see, the problem with r is it
- won't open it if it doesn't exist, right? So either use the a+ mode or check
- the r+ mode call and if it fails then open with a w+ mode.
-
- One note about the a+ mode. It should put you at the end of the file
- automatically, but you may want to do an fseek just to be sure.
- Also, when you are using a read/write mode, you need to preform an fseek
- between reads and writes (in other words you can't follow an fread with an
- fwrite. You must put an fseek in between), at least when dealing with
- binary files.
-
- +L8R+ +What do you say to the child, whose god
- HonuS internet: TEW105@psuvm.psu.edu|is in the TV? And what do you say to the
- +---+ bitnet: TEW105@psuvm |man, who blames the world on TV? -Live
- Disclaimer: +-Look Ma, only 4 lines--+-I don't know, ask Oprah -me ----------+
- The big wigs at PSU wish they could come up with opinions as good as mine!
-