[comp.lang.c] Microsoft C: Reading binary files.

vivanco@ciit85.ciit.nrc.ca (06/20/91)

I'm posting this for a friend, please email him directly at

mtfirst.eeserv.ee.umanitoba.ca

problem:

   He is using Microsoft C 6.0 and is having trouble reading binary files.

He writes the binary value of a floating point number using fwrite() to a
file. When he tries to read the binary data back it stops because of an
EOF marker (1A). He looked at the file and there are 1A's throughout the
file, the 1A being part of the data. He wants to know how he can read in
the data without determining the physical end of file himself and 
ignoring the EOF fread() reads. Hope this explains the problem.

Thanks in advance,

Rodrigo

ryoung@pollux.svale.hp.com (Roderick Young) (06/26/91)

He's probably checked, but is he sure that he opened the file in
BINARY mode?  A stream opened in character mode will falsely detect
EOF in the manner described.