我很困惑,stdin、stdout 和 stderr 是否有可能在内部指向同一个文件描述符?因为如果我使用 stdin 作为输入或 stdout,如果我想从控制台读取字符串,它在 C 中没有区别。
read(1, buf, 200)这read(0, buf, 200)怎么可能?
read(1, buf, 200)
read(0, buf, 200)
( 0 == STDIN_FILENO == fileno(stdin), 1 == STDOUT_FILENO == fileno(stdout))
0 == STDIN_FILENO == fileno(stdin)
1 == STDOUT_FILENO == fileno(stdout)
c linux stdin stdout io-redirection
c ×1
io-redirection ×1
linux ×1
stdin ×1
stdout ×1