Mail Archives: djgpp/1994/04/10/23:29:05
I want to set STDOUT to raw mode, but leave STDIN in cooked mode but I
can't, WHY?
Consider the following program:
#include <fcntl.h>
main ()
{
char buf[10];
int r;
r = read(0,buf,10);
printf("r=%d\n", r);
_setmode(1, O_BINARY);
r = read(0,buf,10);
_setmode(1, O_TEXT);
printf("r=%d\n", r);
}
If <Enter> is input, the first read returns immediately with 1 character
read (r=1). The second read will not return until 10 more <Enter> keys
are pressed, but still reports r=1. And I'm not setting the mode for STDIN,
but only STDOUT.
What's going on?
Doug Rupp
- Raw text -