File Descriptors and Unix I/O
A file descriptor is a small non-negative integer that represents an open file (or pipe, socket, device) in the kernel’s per-process table. 0 = stdin, 1 = stdout, 2 = stderr. open() returns a new fd, read()/write() transfer bytes, close() releases it. These are raw syscalls — unbuffered, one kernel transition per call. stdio.h (fopen, fread, fprintf) adds userspace buffering on top. The Unix philosophy: everything is a file — the same read/write interface works on files, pipes, sockets, and devices.