home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / os2 / programm / 7338 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.4 KB

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