🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #3285

Re: fread()/fseek()/fwrite() problem?

#3285
From: Bill Sarantakos
Date: Tue, 05 Jan 1993 23:51
22 lines
1365 bytes
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
Technical Details
Message-ID: <19930105.155207.701@almaden.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
References: <C0Dz8s.4u4@panix.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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