Answer the following statements true (T) or false (F)
1. An istream object is already an ifstream object with some extra, added features.
2. When you write
ifstream inStream;
inStream.open(”infile.dat”);
the file, infile.dat must be located in the directory where the program is being run.
3. When you use the open member function to tie a file name to a file stream, the file name is called the external file name, and the program refers to the file by the stream name.
4. A file is automatically closed when a program terminates, so there is never a need to close a file.
5. The flush member function copies the file buffer to the file on the file medium (disk, tape, etc).
1. False
This is backwards. An ifstream object is an istream object, but the ifstream object has features the istream object does not. The ifstream objects have an open member function that ties the stream to a file, but the istream objects do not.
2. False
If infile.dat is not in the directory where the program is being run, you can supply a path in addition to the file name. The details are system dependent. Though this question is predicated on input, the same thing is true of output file streams.
3. True.
In a program, each file has two names, whether the file is for input or output. The external file name is the real name of the file. It is used in the program only as an argument for the open member function. The program always refers to the file using the stream name.
4. False
The statement of the problem is not quite accurate. A program will close a file only if the program terminates normally. It is possible for a file to be left in a corrupt state if the program that opened it terminates abnormally, and does not close the file.
5. True
For reasons of efficiency, files on disk are divided into blocks, usually of size between 512 and 4096 bytes. One or more blocks are kept in memory for reading and writing, and are copied to and read from disk (roughly) on an as-needed basis. The flush function copies the buffer to disk before the system would otherwise do so.
You might also like to view...
BorderLayout implements interface ________.
a. ActionListener b. FlowLayout. c. Layout d. LayoutManager2
structure called Address that contains character arrays streetAddress[25], city[20], state[3] and zipCode[6].
What will be an ideal response?
You can make a presentation ____, which means that others can read but cannot modify the presentation.
A. change-free B. modify-free C. read-only D. look-only
A laser printer?s ______________ exposes the entire surface of the photosensitive drum to light, causing any electrical charge present in the particles to bleed into the grounded drum.
Fill in the blank(s) with the appropriate word(s).