Difficulty: Easy
Correct Answer: open "source.txt" in binary mode for reading
Explanation:
Introduction / Context:The fopen mode string controls how a file is opened—text vs binary, reading vs writing, appending, and whether a new file is created or an existing one is truncated. Choosing the correct mode avoids data loss and platform-specific newline translations.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Parse "r" → open for reading only.Parse "b" → open in binary mode (no newline conversion).Therefore, "rb" means open in binary mode for reading.Verification / Alternative check:
If the intent were read/write, "rb+" would be required; if write/truncate, "wb" would be used.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
open "source.txt" in binary mode for reading
Discussion & Comments