| Re: NEW_LINE function only returns one character |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Aug 14, 2008 03:49
Clive Page wrote:
(snip)
> I hadn't appreciated that C also behaved that way. One of the (few)
> attractions of C, it seems to me, is the impression that one is getting
> at the bits in memory (or on disc) without any barriers or possibly
> misleading translation stages in the way. Of course the operating
> system is always in the way, but it doesn't always interfere. That's
> one reason why I welcomed the addition of stream I/O in Fortran - in the
> unformatted form at least, it gives the programmer access to the bits in
> any file. Maybe that's an illusion, but so far I've been taken in, and
> most files that I've wanted to read with it have worked as I expected.
C has text mode and binary mode. In text mode, '\n' (a single character)
is translated to/from the OS dependent line end marker. In binary mode,
such translation is not done. Because of the possible translation,
there are restrictions on the use of fseek() and ftell() when used
with text mode files. Other than fseek() to the beginning or end
of a file, only fseek() to positions previously returned by ftell()
is allowed for text files. The default for fopen() is for text
mode unless a 'b' is included in the second argument.
-- glen
|