home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.os2.programmer:7338 comp.lang.c:19275
- Path: sparky!uunet!vnet.ibm.com
- From: bigbill@vnet.ibm.com (Bill Sarantakos)
- Message-ID: <19930105.155207.701@almaden.ibm.com>
- Date: Tue, 5 Jan 93 18:51:56 EST
- Newsgroups: comp.os.os2.programmer,comp.lang.c
- Subject: Re: fread()/fseek()/fwrite() problem?
- Organization: IBM Canada Laboratory
- Disclaimer: This posting represents the poster's views, not those of IBM
- News-Software: UReply 3.0
- References: <C0Dz8s.4u4@panix.com>
- Lines: 22
-
- In <C0Dz8s.4u4@panix.com> Larry Salomon Jr. writes:
- >It is my code or is the following a problem?
- >
- >pfFile=fopen("ABCD","r+b");
- >fread(achLine,sizeof(achLine),1,pfFile);
- >fread(&sMyStruct,sizeof(sMyStruct),1,pfFile);
- >
- >/* @@ */
- >sMyStruct.bCheckedout=TRUE;
- >fseek(pfFile,sizeof(achLine),SEEK_SET);
- >fwrite(&sMyStruct,sizeof(sMyStruct),1,pfFile);
- >/* @@ */
-
- Before one can output/input after having input/output, a fflush()
- or file positioning function (fseek, fsetpos, or rewind) must be called
- (see top of page 131 in ANSI spec). While the above code appears to
- be OK, perhaps the context from which it was taken is incorrect. If
- you think the runtime is being over-zealous and disallowing this
- case (since using rewind() actually works), send a test case to
- cset2@vnet.ibm.com along with a note explaining the problem.
-
- Bill Sarantakos OS/2 C++ Compiler Development Toronto, Ontario
-