Mail Archives: djgpp/1994/05/30/04:25:57
Mike Castle wrote:
> Amazingly enough eliz AT is DOT elta DOT co DOT il said:
> > My question is: is there ANY way to change open mode (TEXT vs
> > BINARY) of the stdin stream WITHOUT reopening it (which we
> > obviously cannot do, as indicated by Eric Backus)? I think there
> > is no PORTABLE (i.e. ANSI) way, but maybe something DOS-specific
> > or DJGPP-specific?
>
> setmode(fileno(FILE*),O_BINARY);
Yes, this is the solution. The only thing I would add is: don't
forget about buffering. For example, if you write a line in text mode
with fprintf(), then switch to binary mode, and then write a block,
the stdio buffering may cause you problems. When there is any doubt,
I've found it best to fflush() before doing setmode().
--
Eric Backus
ericb AT lsid DOT hp DOT com
(206) 335-2495
- Raw text -