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).
You might also like to view...
The ____ provides a code template for every event procedure.
A. Code Editor B. Template Editor C. Code Template D. Template Tool
Which of the following statements are correct?
a. When you create an array using new int[10], an array object is created with ten integers of value 0. b. When you create an array using new int[10], an array object is created with no values in the array. c. When you create an ArrayList using new ArrayList(), an ArrayList object is created with no elements in the ArrayList object. d. When you create an array using int[] x = new int[10], x.length() is 10. e. When you create an array using ArrayList x = new ArrayList(10), x.size() is 10.