Difficulty: Easy
Correct Answer: Read and Write
Explanation:
Introduction / Context:In C standard I/O, the two-character (or three-character) mode string passed to fopen controls not only whether a file is opened for reading or writing, but also whether it is treated as text or binary, whether content is preserved or truncated, and whether writes append at end. Understanding the exact meaning of each mode prevents accidental data loss and enables the correct combination of reading and writing behaviors for update-style workflows.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Interpret 'r+' → existing file, readable and writable, no truncation.Check appending semantics → not implied; writes start at current position (often the beginning) unless moved.Therefore, the permitted operations are both reading and writing (update I/O), not append-only.Verification / Alternative check:
Compare with related modes: 'w+' creates/truncates then read/write; 'a+' opens (or creates) and positions at end for each write (append), still allowing reads after seeks.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
Read and Write
Discussion & Comments