I just don't spend enough time "tinkering" with *nix. Anyhow when I
read from an unbuffered input and type something in, I get two prompts
after I hit return.
m-net% more tty.c
m-net% ./ttyCode:#include <stdio.h> int main(void) { char c; return(read(0, &c, 1) == 1) ? (unsigned char)c : EOF; return 0; }
c
m-net%
m-net%
Now when I buffer the input, and type something in, I only get one
prompt after I hit return.
m-net% more tty2.c
m-net% ./tty2Code:#include <stdio.h> int main(void) { static char buf[BUFSIZ]; static char *bufp = buf; static int n = 0; if(n == 0) { n = read(0,buf, sizeof buf); bufp = buf; } return (--n >= 0) ? (unsigned char) *bufp++ : EOF; }
c h a d
m-net%
Why is this?



LinkBack URL
About LinkBacks


