home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16792 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.4 KB  |  31 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!portal!dfuller
  3. From: dfuller@portal.hq.videocart.com (Dave Fuller)
  4. Subject: Re: fwrite & fread
  5. Message-ID: <Bxyuzp.5Dq@portal.hq.videocart.com>
  6. Organization: VideOcart Inc.
  7. X-Newsreader: Tin 1.1 PL3
  8. References: <92324.000622U17868@uicvm.uic.edu>
  9. Date: Thu, 19 Nov 1992 14:02:13 GMT
  10. Lines: 19
  11.  
  12. U17868@uicvm.uic.edu () writes:
  13. : I am using write & fread to read and write to a file. The structure that I
  14. : am writing has 194 bytes. After executing fwrite I check the value, in vari
  15. : able a which is 1 (correct), because I am writing one structure. Then I check
  16. : the values of returned by fclose and ferror and they are also correct i-e 0.
  17. : But when I quit from the program without writing more structures or without
  18. : running any other functions and look for the size of my file it shows that it
  19. : has 414 bytes. Actually, it should have 194 bytes. I have tried with different
  20. : file modes, but that doesn't solve the problem. I have also tried with a file
  21. : initially empty and with a file having some records. Therefore, I tried clearin
  22. : g the buffer, but that also doesn't help. For those of you who might be interes
  23. : ted in the code, I have it below. Don't pay attention towards syntax errors.
  24.  
  25.   The problem probably is that you are seeing the file size that the OS has
  26. used up. If the OS writes in block mode instead of char mode it will do
  27. this.
  28.  
  29. Dave Fuller
  30. dfuller@portal.hq.videocart.com 
  31.