Binary I/O on stdin/stdout?

Karl Heuer karl at haddock.ISC.COM
Wed Mar 30 07:42:12 AEST 1988


In article <8036 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>> > There seems to be *no way* to "reopen" these streams as binary.
>> There was a proposal for freopen((char*)0,mode,stream) to effect
>> a change of mode on an open stream, but several implementors
>> thought that switching modes in midstream could be difficult to
>> support on some systems.
>
>Couldn't freopen simply return ((FILE *) 0) in such cases, much as
>localtime is allowed to return -1 if local time can't be determined?

That's time(), not localtime().

Let's consider three classes of machines.  Those on which text and binary
streams are identical (POSIX); those on which such a mode-change is impossible
(probably because the mode is set in concrete when the file is first opened);
and those on which it is neither trivial nor impossible.

The proposed functionality is only useful on the third class.  Are there any
such implementations?  (Where do MSDOS and VMS fall?)

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list