C++ Chapter 12

25 July 2022
4.7 (114 reviews)
25 test answers

Unlock all answers in this set

Unlock answers (21)
question
This term means non-sequentially accessing information in a file.
answer
random access
question
Outside of a C++ program, a file is identified by its ________. Inside a C++ program, a file is identified by a(n) ________.
answer
name, file stream object
question
This state bit can be tested to see if the end of an input stream is encountered.
answer
ios::eofbit
question
ofstream, ifstream, and fstream are:
answer
data types
question
This data type can be used to create files and read information from them into memory.
answer
ifstream
question
In order, the three-step process of using a file in a C++ program involves:
answer
Open the file, read/write/save data, close the file
question
To access files from a C++ program, you must use this directive:
answer
#include
question
This data type can be used to create files and write information to them but cannot be used to read information from them.
answer
ofstream
question
When a file is opened, the file stream object's "read position" is ________.
answer
at the beginning of the file
question
Data stored here disappears once the program stops running or the computer is powered down.
answer
in RAM
question
Which of the following statements opens the file info.txt for both input and output?
answer
dataFile.open("info.txt", ios::in | ios::out);
question
This member function reads a single character from a file.
answer
get
question
The end-of-file marker is automatically written ________.
answer
when a file is closed
question
All stream objects have ________, which indicate the condition of the stream.
answer
error state bits
question
This member function can be used to store binary data to a file.
answer
write
question
To set up a file to perform file I/O, you must declare:
answer
one or more file stream objects
question
When used by itself, this access flag causes a file's contents to be deleted if the file already exists.
answer
ios::out
question
Which statement opens a file in such a way that information will only be written to its end?
answer
dataFile.open("info.dat", ios::out | ios::app);
question
Closing a file causes any unsaved information still held in the file buffer to be ________.
answer
saved to the file
question
This state bit is set when an attempted operation has failed
answer
ios::failbit
question
Which statement opens a file and links it to a file stream object?
answer
file.open("c:filename.txt");
question
What is true about the following statement? out.open("values.dat", ios::app);
answer
If the file already exists, its contents are preserved and all output is written to the end of the file.
question
This data type can be used to create files, read data from them, and write data to them.
answer
fstream
question
This member function writes a single character to a file.
answer
put
question
The ________ marker is the character that marks the end of a file, and is automatically written when the file is closed.
answer
End of File (EOF)