Search code examples
cmacrossystem-callsfile-descriptor

Are there any standard input/ouput macros for read/write system calls in C?


All my searches returned nothing and I find it odd that there aren't any macros to use as file descriptors for read/write system calls for standard input and output instead of a 0 (stdout) and a 1 (stdin).

Am I missing them or they really don't exist?


Solution

  • They exist in unistd.h on a POSIX machine. STDOUT_FILENO, STDIN_FILENO, and STDERR_FILENO. See: http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html