I am trying to understand stdin
, stdout
...and these are few questions i have
int main()
{
struct t开发者_如何学JAVAermios new;
tcgetattr(1,&new);
new.c_lflag &= ~ECHO;
tcsetattr(1,TCSAFLUSH,&new);
return 0;
}
I want to know what happens if i turn ECHO
off on stdin
rather than stdout
....i mean, in both the cases i experience same result....how do they differ??
And what does stty
command returns??
stty
and found -echo for line=0, if i am right, it is ECHO
off on stdin
, but the program turns the ECHO
flag off for stdout
??
Sorry, if my doubts sound noob :( This is terminal control. And if both your stdin and stdout are connected to the same terminal, then you are still managing the same objects configuration.
tcgetattr
simply gets information about the object associated with the filedescriptor.
Of course they don't have to be associated with the same terminal. For example if you run:
./a.out >file.out
then stdin will still be attached to the terminal, but stdout is now attached to a file.
精彩评论