开发者

trying to understand stdin, stdout

开发者 https://www.devze.com 2023-03-09 03:04 出处:网络
I am trying to understand stdin, stdout...and these are few questions i have here\'s the code i am using:

I am trying to understand stdin, stdout...and these are few questions i have

here's the code i am using:

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??

After running the above program, i did 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消