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