|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Why do I get an extra return in thie following case?
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 #include <stdio.h> int main(void) { char c; return(read(0, &c, 1) == 1) ? (unsigned char)c : EF; return 0; } m-net% ./tty 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 #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 ( >= 0) ? (unsigned char) *bufp++ : EF; } m-net% ./tty2 c h a d m-net% Why is this? Chad |
![]() |
| Viewing: Web Development Archives > FAQs > Unix/Linux > Why do I get an extra return in thie following case? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|