Chapter 13 Advanced File Operations
backwards
A negative offset causes the file's read or write position to be moved _____ in the file from the position specified by the mode.
fields
A record is a complete set of information about a single item and is made up of ______.
filename
All files are assigned a(n) ____ that is used for identification purposes by the operating system and the user.
opened
Before a file can be used, it must first be ______.
0
If a file fails to open, the file stream object will be set to ______.
structs
In C++, _____ provide convenient way to organize information into fields and records.
sequential
In ____ file access, the contents of the file are read in the order they appear in the file, from the file's start to its end.
random
In _____ file access, the contents of a file may be read in any order.
get
The ___ member function reads a single character from a file.
seekg
The ____ member function moves a file's read position to a specified byte in the file.
tellg
The ____ member function returns a file's current read position.
ios::cur
The ____ mode flag causes an offset to be calculated from the current position in the file.
getline
The _____ function reads a line of text from a file.
fstream
The _____ header file is required for file I/O operations.
seekp
The _____ member function moves a file's write position to a specified byte in the file.
read
The _____ member function reads "raw" binary data from a file.
.eof()
The _____ member function reports when the end of the file has been encountered.
tellp
The _____ member function returns a file's current write position.
write
The _____ member function writes "raw" binary data to a file.
put
The _____ member function writes a single character to a file.
ios::beg
The _____ mode flag causes an offset to be calculated from the beginning of a file.
ios::end
The _____ mode flag causes an offset to be calculated from the end of a file.
<char*>
The _____ operator is necessary if you pass anything other than a pointer to char as the first argument of the two functions mentioned in question.
fstream
The ______ file stream data type is for output files, input files, or files that perform both input and output.
ifstream
The _______ file stream data type is for input files.
ofstream
The ________ file stream data type is for output files.
cout
The same formatting techniques used with _____ may also be used when writing information to a file.
ifstream ofstream fstream
The three file stream data types are ______, _______, and ______.
close
When a program is finished using a file, it should ____ it.
ofstream people("people.dat");
Write a statement that defines a file stream object named people. The object will be used for file output.
istream pets;
Write a statement that defines a file stream object named pets. The object will be used for file input.
fstream places("places.dat");
Write a statement that defines a file stream object named places. The object will be used for both output and input.
ofstream people("people.dat", ios::out); people.open("people.dat", ios::out);
Write two statements that use the people file stream object to open a file named people.dat. (Show how to open the file with a member function and at definition.) The file should be opened for output.
ifstream pets("pets.dat", ios::in); pets.open("pets.dat", ios::in);
Write two statements that use the pets file stream object to open a file named pets.dat. (Show how to open the file with a member function and at definition.) The file should be opened for input.
fstream places ("places.dat", ios::in | ios::out); places.open("places.dat", ios::in | ios::out);
Write two statements that use the places file stream object to open a file named places.dat. (Show how to open the file with a member function and at definition.) The file should be opened for both input and output.
Binary
_____ files contain data that is unformatted and not necessarily stored as ASCII text.
Text
______ files contain information formatted as ASCII text.