You have a file that is not empty, and you want to preserve the contents and append to the end of the file. Give the commands necessary to open a file for appending.

What will be an ideal response?


```
#include
//. . .
using std::ofstream;
using std::ios;
ofstream outStream;
outStream.open(“myFile.txt”, ios::app);
```

The using declarations of ofstream and ios make these name available. The first argument is the system name of the file to be opened. The second, ios::app, is an optional argument for the open member function that causes the file to be opened with the write position at end of file and causes writes to the file to be appended.

Computer Science & Information Technology

You might also like to view...

In order to hide functions that are defined in the implementation file, they should be part of the ______________ namespace.

a. global b. std c. class d. unnamed

Computer Science & Information Technology

Launched in 2001, ________ was the first dedicated social bookmarking service

Fill in the blank(s) with correct word

Computer Science & Information Technology

When data is consolidated and links to the source data are included, the consolidation will NOT be automatically updated when changes are made to the source data

Indicate whether the statement is true or false

Computer Science & Information Technology

If you attempt to open a file with the Open file mode, what happens if the file does not exist?

A. The file is created and then opened for use. B. The program returns a prompt to the user asking if the file should be created. C. The program will return a null object, and all data written to the file will be discarded. D. The program throws a System.IO.FileNotFoundException error.

Computer Science & Information Technology