Fill in the blanks in each of the following:
Ultimately, all data items processed by a computer are reduced to combinations of__________and__________.
The smallest data item a computer can process is called a__________.
A(n)__________is a group of related records.
Digits, letters and special symbols are referred to as__________.
A group of related files is called a(n)__________.
Member function__________of the file streams fstream, ifstream and ofstream closes a file.
The istream member function__________reads a character from the specified stream.
Member function__________of the file streams fstream, ifstream and ofstream opens a file.
The istream member function__________is normally used when reading data from a file in random-access applications.
Member functions__________and__________of istream and ostream, set the file-position pointer to a specific location in an input or output stream, respectively.
State which of the following are true and which are false. If false, explain why.
Member function read cannot be used to read data from the input object cin.
The programmer must create the cin, cout, cerr and clog objects explicitly.
A program must call function close explicitly to close a file associated with an ifstream, ofstream or fstream object.
If the file-position pointer points to a location in a sequential file other than the beginning of the file, the file must be closed and reopened to read from the beginning of the file.
The ostream member function write can write to standard-output stream cout.
Data in sequential files always is updated without overwriting nearby data.
Searching all records in a random-access file to find a specific record is unnecessary.
Records in random-access files must be of uniform length.
Member functions seekp and seekg must seek relative to the beginning of a file.
Assume that each of the following statements applies to the same program.
Write a statement that opens file oldmast.dat for input; use an ifstream object called inOldMaster.
Write a statement that opens file trans.dat for input; use an ifstream object called inTransaction.
Write a statement that opens file newmast.dat for output (and creation); use ofstream object outNewMaster.
Write a statement that reads a record from the file oldmast.dat. The record consists of integer accountNumber, string name and floating-point currentBalance; use ifstream object inOldMaster.
Write a statement that reads a record from the file TRans.dat. The record consists of integer accountNum and floating-point dollarAmount; use ifstream object inTransaction.
Write a statement that writes a record to the file newmast.dat. The record consists of integer accountNum, string name, and floating-point currentBalance; use ofstream object outNewMaster.
Find the error(s) and show how to correct it (them) in each of the following.
File payables.dat referred to by ofstream object outPayable has not been opened.
outPayable << account << company << amount << endl;
The following statement should read a record from the file payables.dat. The ifstream object inPayable refers to this file, and istream object inReceivable refers to the file receivables.dat.
inReceivable >> account >> company >> amount;
The file tools.dat should be opened to add data to the file without discarding the current data.
ofstream outTools( "tools.dat", ios::out );