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);
Explanation: 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...

Describe the ways in which the request-reply protocol masks the heterogeneity of operating systems and of computer networks.

What will be an ideal response?

Computer Science & Information Technology

Explain and motivate in-network processing for wireless sensor networks

What will be an ideal response?

Computer Science & Information Technology