Which of the following is correct for opening a file and attaching it to a file named File.txt? Assume proper file inclusion and proper using directives.

a) ```
open(outStream, “File.txt”, ios::app)
```

b) ```
ifstream inStream;
inStream.open(“File.txt”);
```

c) ```
ifstream inStream(“File.txt”);
```

d) ```
ofstream inStream;
onStream.open(“File.txt”, ios::app);
```

e) ```
ifstream inStream(“File.txt”, ios::app);
```


All but a) are correct.

Part a) mistakes the open member function for a standalone function. Part b) declares the stream and separately calls the open member function for input. Part c) is the abbreviated form to open File.txt. Part d) is the detailed open for append. Part e) is the abbreviated form of d).

Computer Science & Information Technology

You might also like to view...

The collection of commands that a CPU executes is called the instruction set

Indicate whether the statement is true or false

Computer Science & Information Technology

Suppose that class template Employee has a static data member count. Suppose that three class-template specializations are instantiated from the class template. How many copies of the static data member will exist? How will the use of each be constrained (if at all)?

What will be an ideal response?

Computer Science & Information Technology

You can save a search file to a portable storage device such as a floppy disk

Indicate whether the statement is true or false

Computer Science & Information Technology

The contention method used in Ethernet is called Token passing

Indicate whether the statement is true or false.

Computer Science & Information Technology