VMS Specific question about binary reads using fgetc

Bradford R. Daniels daniels at hanoi.enet.dec.com
Fri Jun 15 07:30:14 AEST 1990


The VAX C RTL tries to "do the right thing" with record files.
If the file has a carriage control attribute (e.g. carriage
return carriage control in this case), it will (by default)
append a newline to each record as it is read in.  Your fopen()
statement, however, specifies "rb" as the file open mode, or
"read only in binary mode".  This specification that the file
is binary overrides C's default carriage control interpretation,
and you get the data unadorned, as it were, with newlines.  This
is fine if you're truly reading a binary file which just happens
to be in variable record format, but in the case of the file in
question, the record format is significant, and the file is not,
in fact, simply binary data.

Hope this helps.

- Brad

-----------------------------------------------------------------
Brad Daniels			|  Digital Equipment Corp. almost
DEC Software Devo		|  definitely wouldn't approve of
"VAX C RTL Whipping Boy"	|  anything I say here...



More information about the Comp.lang.c mailing list