Multiple choice

Which of the following program codes is correct for opening a file in append mode that sets the write pointer to end of a file?

  1. fstream f1; f1.open(TEXT.DAT, ios::app);

  2. ifstream f1; f1.open(TEXT.DAT, ios::app);

  3. ofstream f1; f1.open(TEXT.DAT, ios::trunc);

  4. fstream f1; f1.open(TEXT.DAT, ios::out);

  5. fstream f1; f1.open(TEXT.DAT, ios::in);

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This code is correct for opening a file in append mode that sets the write pointer to the end of a file.