Closing/reopening stdin in binary mode w/ Turbo C 2.0 
Author Message
 Closing/reopening stdin in binary mode w/ Turbo C 2.0


> : Could someone please send me some information on reopening stdin in binary
> : mode after closing it. I am writing a program that needs to read in binary
> : data from a pipe and it doesn't read in the entire file. It seems to trip
> : on the first ^Z it comes to.

> Reopening stdin in binary mode will not help, because DOS does not
> support binary pipes.

I'm reluctant to followup to this (note also that further
followups are redirected), because I'm not sure that displaying
knowledge of MS-DOS arcana is any mark of virtue, but this
assertion is incorrect.  In fact, MS-DOS does not formally
"support" a text vs. binary distinction at all.  (If it did,
there would be a bit in file status information saying whether
a file was text or binary, and you wouldn't have to specify
text or binary mode when opening existing files, and you would
have to specify text or binary when creating new files.  VMS is
an example of a system which does support binary files in this
way.)  In MS-DOS, text vs. binary distinctions are only
conventions, and their manifestations in C reside solely within
C's run-time library.

Once closed, it is generally impossible to reopen stdin properly.
However, when you need to, there's usually a way to control the
bits within the run-time library's I/O routines which control a
stream's interpretation (i.e. whether text or binary conventions
are being used).  In Microsoft C, you used to be able to do

        setmode(fileno(stdin), O_BINARY);

I suspect it's called _setmode() or __setmode() now, but in any
case, Borland ought to provide an equivalent mechanism.

Tue, 11 Mar 1997 23:11:22 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Can a process close and reopen stdin

2. Binary and Text Modes and Stdin/Stdout

3. Using STDIN in BINARY mode...

4. MSC6.0 - Binary Stdin Mode

5. Binary mode stdin

6. 43/50-line mode for EGA/VGA for Turbo C 2.0

7. reopening stdin and stdout

8. Turbo C 2.0 vs. Turbo Pascal 6.0

9. Turbo C 2.0 And Turbo C++ Library Compatibility?

10. DAO multiple Addnew's requires closing and reopening of Recordset

11. How to close and reopen an OLE DB?

12. How to close and reopen OLE DB?


Powered by phpBB® Forum Software