Difficulty: Easy
Correct Answer: ios::in
Explanation:
Introduction / Context:When working with std::fstream, std::ifstream, or std::ofstream, you specify open modes using std::ios flags. Correct selection of flags controls whether the file is opened for reading, writing, appending, truncation, or binary access. This question focuses on the flag that enables input operations.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Identify the correct constant: ios::in.Example: std::ifstream f("data.txt", std::ios::in); enables reads with operator>> or read().Therefore, the correct answer is ios::in.Verification / Alternative check:
Opening with std::ifstream f("file"); implicitly uses ios::in; attempting to write will fail since it is read-only.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
ios::in
Discussion & Comments