Deck 13: Advanced File and Io Operations
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/38
Play
Full screen (f)
Deck 13: Advanced File and Io Operations
1
The operating system records the information that tracks the end of the file
A)when the program ends.
B)when a file is closed.
C)when a file is opened with ios::app.
D)when a file is opened with ios::eof.
E)None of the above
A)when the program ends.
B)when a file is closed.
C)when a file is opened with ios::app.
D)when a file is opened with ios::eof.
E)None of the above
B
2
Outside of a C++ program, a file is identified by its . Inside a C++ program, a file is accessed through a .
A)name, address
B)file name, file number
C)name, file stream object
D)file number, file name
E)None of the above
A)name, address
B)file name, file number
C)name, file stream object
D)file number, file name
E)None of the above
C
3
The function can be used to store binary data to a file.
A)binary.out
B)put
C)write
D)dataout(binary)
E)None of the above
A)binary.out
B)put
C)write
D)dataout(binary)
E)None of the above
C
4
The member function, _, reads a single character from a file.
A)input
B)get
C)put
D)read
E)None of the above
A)input
B)get
C)put
D)read
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
5
All stream objects have that indicate the condition of the stream.
A)error state bits
B)markers
C)intrinsic error messages
D)condition statements
E)None of the above
A)error state bits
B)markers
C)intrinsic error messages
D)condition statements
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
6
The process of writing in- memory objects to a file so that the object can later be read back into memory
A)requires special operation system support.
B)is called deserialization.
C)requires the use of specialized convert constructors.
D)is called serialization.
E)None of the above
A)requires special operation system support.
B)is called deserialization.
C)requires the use of specialized convert constructors.
D)is called serialization.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
7
The statement dataFile.close();
A)is legal but risks losing valuable data.
B)needs a file name argument to execute correctly.
C)is illegal in C++.
D)closes a file.
E)None of the above
A)is legal but risks losing valuable data.
B)needs a file name argument to execute correctly.
C)is illegal in C++.
D)closes a file.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
8
Data stored is lost when the computer is powered down.
A)on CD ROM
B)in RAM
C)on the hard disk
D)on a backup tape
E)None of the above
A)on CD ROM
B)in RAM
C)on the hard disk
D)on a backup tape
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
9
The state bit,
A)ios::eof
B)ios::failbit
C)ios::badbit
D)ios::eofbit , can be tested to see if the end of an input stream has been encountered.
E)None of the above
A)ios::eof
B)ios::failbit
C)ios::badbit
D)ios::eofbit , can be tested to see if the end of an input stream has been encountered.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
10
ofstream, ifstream, and fstream are
A)libraries.
B)string arrays.
C)data types.
D)header files.
E)None of the above
A)libraries.
B)string arrays.
C)data types.
D)header files.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
11
A file _ is a small holding section of memory that file- bound information is first written to.
A)name
B)number
C)segment
D)buffer
E)None of the above
A)name
B)number
C)segment
D)buffer
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
12
Closing a file causes any buffered information to be
A)saved to the file.
B)duplicated.
C)deleted.
D)stored in a buffer for safekeeping.
E)None of the above
A)saved to the file.
B)duplicated.
C)deleted.
D)stored in a buffer for safekeeping.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
13
The state bit is set when an attempted operation has failed.
A)ios::badbit
B)ios::goodbit
C)ios::hardfail
D)ios::failbit
E)None of the above
A)ios::badbit
B)ios::goodbit
C)ios::hardfail
D)ios::failbit
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
14
The data type can be used to create files and write information to them.
A)ofstream
B)ostream
C)istream
D)ifstream
E)None of the above
A)ofstream
B)ostream
C)istream
D)ifstream
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
15
The data type can be used to connect to files and read information from them into memory.
A)ifstream
B)instream
C)ofstream
D)istream
E)None of the above
A)ifstream
B)instream
C)ofstream
D)istream
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
16
When a file is opened for reading, the file stream object's "read position" is
A)at the end of the file.
B)nonexistent, until the programmer declares it.
C)at the beginning of the file.
D)in the middle of the file.
E)None of the above
A)at the end of the file.
B)nonexistent, until the programmer declares it.
C)at the beginning of the file.
D)in the middle of the file.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
17
The may be used to read information from a file.
A)the stream insertion operator
B)stream extraction operator
C)file.in macro
D)cout object
E)None of the above
A)the stream insertion operator
B)stream extraction operator
C)file.in macro
D)cout object
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
18
The member function reports when the end of a file has been found.
A)stop()
B)eof()
C)end()
D)done()
E)None of the above
A)stop()
B)eof()
C)end()
D)done()
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
19
To access files from a C++ program, you must #include
A) .
B) .
C) .
D) .
E)None of the above
A)
B)
C)
D)
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
20
The may be used to write information to a file.
A)fileWrite() function
B)stream insertion operator <<
C)pen object
D)cout object
E)None of the above
A)fileWrite() function
B)stream insertion operator <<
C)pen object
D)cout object
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
21
To set up a file to perform file I/O, you must declare
A)at least one variable to write to the file.
B)a string array to store the file contents.
C)one or more file stream objects.
D)All of the above
E)None of the above
A)at least one variable to write to the file.
B)a string array to store the file contents.
C)one or more file stream objects.
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
22
The member function
A)write
B)get
C)insert
D)put
E)None of the above
A)write
B)get
C)insert
D)put
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
23
A file must be
A)initialized
B)closed
C)opened
D)declared _ before data can be written to or read from it.
E)None of the above
A)initialized
B)closed
C)opened
D)declared _ before data can be written to or read from it.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
24
File output may be formatted the same way as screen output.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
25
The stream member function fail() can be used to determine whether the last operation performed on a stream was successful.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
26
When used by itself, _ causes a file's contents to be deleted if the file already exists.
A)ios::in
B)ios:app
C)ios::out
D)All of the above
E)None of the above
A)ios::in
B)ios:app
C)ios::out
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
27
The ios::hardfail bit is set when an unrecoverable error occurs.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
28
To write to a binary file, you can use the write() member function of an ofstream
object.
object.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
29
Opening a file with the flags ios::in | ios::out will preserve the contents of the file if the file already exists.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
30
string objects cannot be stored to a binary file without further processing because they contain pointers.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
31
The operation of moving to a particular location in an input file is accomplished through
A)the locate member function.
B)the seekg member function.
C)the seekp member function.
D)the move member function.
E)None of the above
A)the locate member function.
B)the seekg member function.
C)the seekp member function.
D)the move member function.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
32
When you store data in a variable, it is automatically saved in a file.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
33
The read and write member functions of fstream objects can only work with buffers specified by pointers to char.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
34
When the >> operator extracts information from a file, it expects to read data that are separated by
A)commas.
B)whitespace.
C)tabs.
D)semicolons.
E)None of the above
A)commas.
B)whitespace.
C)tabs.
D)semicolons.
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
35
When you assign a name to a file, the operating system identifies the file by that name.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
36
The term means non- sequentially accessing information in a file.
A)cin.getrandom
B)random access
C)read.randomly
D)cin.getline
E)None of the above
A)cin.getrandom
B)random access
C)read.randomly
D)cin.getline
E)None of the above
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
37
An alternative to using the open member function is to use the file stream object declaration itself to open the file.
Example: fstream dataFile("names.dat",ios::in|ios::out);
Example: fstream dataFile("names.dat",ios::in|ios::out);
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
38
Only one file stream object can be declared per C++ program.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck