Chapter 14 File processing 1. All data items processed by a computer are reduced to combinations of zeros and ones. 2. Digits, letters, and special symbols are referred to as characters. The set of all characters that may be used to write programs and represent data items on a particular computer is called that computer's character set. Every character in the character set is repsented as a bit pattern. 3. Sequential access is the most popular method of processing data in a file. 4. A collection of programs designed to create and manage databases is called a database management system (DBMS). 5. C++ views each file as a sequential stream of bytes. 6. The header files and must be included in a program to perform C++ file I/O. Header includes the definitions for the stream classes ifstream, ofstream, and fstream. 7. Files are opened simply by instantiating objects of stream classes ifstream, ofstream and fstream. 8. C++ imposes no structure on a file. Thus, notions like "record" do not exist in C++. The programmer must structure a file to meet the requirements of a particular application. 9. A "get pointer" indicates the position in the file from which the next input is to occur, and a "put pointer" indicates the position in the file at which the next output is to be placed. Both the istream class and the ostream class provide member functions for repositioning the file position pointer. The functions are seekg ("seek get") for class istream and seep ("seek put") for the ostream class. 10. Member functions tellp and tellg return the current locations of the "put" and "get" pointers, respectively. 11. A convenient way to implement random access files is by using only fixed-length records. Using this technique, a program can quickly calculate the exact location of a record relative to the beginning of the file. 12. Data can be inserted in a random access file without destroying other data in the file. Data can be updated or deleted without rewriting the entire file. 13. The ostream member function write outputs to a specified stream some number of bytes beginning at a designated location in memory. 14. The istream member function read inputs some number of bytes from the specified stream to an area in memory beginning at a designated address. 15. The write function expects a first argument of type const char *, so this argument must be cast to const char * if it is of some other pointer type. The second argument is an integer that specifies the number of bytes to be written. 16. The ios member function eof determines if the end of file indicator has been set for the designated stream. End-of-file is set after an attempted read fails. 17. Open a file for input only (using ios::in) if the contents of the file should not be modified. This is an example of the principle of least privilege. 18. Explicitly close each file as soon as it is known that the program will not reference the file again. This practice also improve the program clarity.