File Processing: 2006 Pearson Education, Inc. All Rights Reserved
File Processing: 2006 Pearson Education, Inc. All Rights Reserved
File Processing: 2006 Pearson Education, Inc. All Rights Reserved
1
7
File Processing
OBJECTIVES
In this chapter you will learn:
To create, read, write and update files.
Sequential file processing.
Random-access file processing.
To use high-performance unformatted I/O
operations.
The differences between formatted-data and
raw-data file processing.
To build a transaction-processing program
using random-access file processing.
17.1 Introduction
17.2 The Data Hierarchy
17.3 Files and Streams
17.4 Creating a Sequential File
17.5 Reading Data from a Sequential File
17.6 Updating Sequential Files
17.7 Random-Access Files
17.8 Creating a Random-Access File
17.9 Writing Data Randomly to a Random-Access File
17.10 Reading from a Random-Access File Sequentially
17.11 Case Study: A Transaction-Processing Program
17.12 Input/Output of Objects
17.13 Wrap-Up
17.1 Introduction
• Files
– Used for data persistence
• Permanent retention of large amounts of data
– Stored on secondary storage devices
• Magnetic disks
• Optical disks
• Tapes
Mode Description
ios::app Append all output to the end of the file.
ios::ate Open a file for output and move to the end of the file (normally used to
append data to a file). Data can be written anywhere in the file.
ios::in Open a file for input.
ios::out Open a file for output.
ios::trunc Discard the file’s contents if they exist (this also is the default action
for ios::out).
ios::binary Open a file for binary (i.e., nontext) input or output.
Fig. 17.6 | End-of-file key combinations for various popular computer systems.