Which combination opens an existing file for both reading and writing without requesting truncation?

Options

  • A. ios::out | ios::trunc
  • B. ios::in | ios::out
  • C. ios::app
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. ios::in | ios::out

Detailed Explanation

Correct Answer: Option B

Explanation: ios::in | ios::out requests both input and output without explicitly requesting truncation. When opening an existing file this way, its existing contents are not automatically erased. If the file does not exist, opening with these modes generally fails.