Master file operations in C: streams, buffering, text vs binary modes, and low-level POSIX I/O for real system programming.
C uses a stream abstraction. A FILE pointer tracks the file, position, and error state.
fopen returns NULL before using the file pointer. Always fclose to flush buffers and release resources.
How you intend to use the file determines the mode string.
Opens existing file for reading. Fails if file doesn't exist. Pointer at start.
Creates new file for writing. DESTROYS content if file exists. Pointer at start.
Writes to the end of file. Preserves content. Creates file if missing.
"r+": Read/Write (File must exist)"w+": Read/Write (Truncates file)"a+": Read/Append
Understanding how data is serialized.
Translates newlines (\n -> \r\n on Windows). Good for human-readable logs.
Raw byte dump. No translation. Essential for images, structs, and custom formats.
Moving the cursor and checking status.
System calls used by the OS kernel (Linux/Unix). Unbuffered and raw.