Strange behavior performing library functions on STDOUT and STDIN's file descriptors
Throughout my years as a C programmer, I've always been confused about the standard stream file descriptors. Some places, like Wikipedia [1] , say: In the C programming language, the standard input, output, and error streams are attached to the existing Unix file descriptors 0, 1 and 2 respectively. This is backed up by unistd.h : /* Standard file descriptors. */ #define STDIN_FILENO 0 /* Standard input. */ #define STDOUT_FILENO 1 /* Standard output. */ #define STDERR_FILENO 2 /* Standard error output. */ However, this code (on any system): write(0, "Hello, World!\n", 14); Will print Hello,