FILE Pointers & fopen Modes
Opening, reading, writing, and closing streams safely
| Mode | Action | File Must Exist? | Starting Position |
|---|---|---|---|
"r" | Read text file | Yes (fails if missing) | Beginning of file |
"w" | Write text file (Overwrites / Truncates to 0) | No (created if missing) | Beginning of file |
"a" | Append text file (Preserves old contents) | No (created if missing) | End of file |
"rb" / "wb" | Read / Write Binary files (No newline translation) | Same as text | Beginning of file |
"r+" / "w+" | Read and Write (Update mode) | Yes / No | Beginning of file |