www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/25/01:08:24

Date: Tue, 25 Jul 1995 07:50:48 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: kagel AT quasar DOT bloomberg DOT com
Cc: dpsm AT lubrizol DOT com, djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Text/Binary mode of stdin,stdout,stderr

On Mon, 24 Jul 1995 kagel AT quasar DOT bloomberg DOT com wrote:

> Try closing stdin/stdout and reopening with mode set to binary:
> 
> 	fclose( stdin );
> 	stdin = fopen( "STDIN", "rb" );
> 	fclose( stdout );
> 	stdout = fopen( "STDOUT", "wb" );
> 
> I believe that the DJGPP library supports these symbolic file names.  If not 
> you could try opening both stdin and stdout on the CON: device.

There is no "STDOUT" and such.  The above method is a bad idea because 
stdin/stdout might have been redirected to another file/device.  Use 
setmode() library function on the file handle, like this:

	setmode(fileno(stdout), O_BINARY);

or, if you are sure stdout wasn't freopen()'ed, you can even do this:

	setmode(1, O_BINARY);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019