tailieunhanh - Chapter 14 - File Processing
File processing is the process of creating, storing and accessing content of files. File processing can be used in opening saved files for read only purpose. It can be used to save a new file or displace the existing one. Through file processing you can make new files and save the existing files. You can also modify files through this process. | Chapter 14 - File Processing Outline Introduction The Data Hierarchy Files and Streams Creating a Sequential-Access File Reading Data from a Sequential-Access File Updating Sequential-Access Files Random-Access Files Creating a Random-Access File Writing Data Randomly to a Random-Access File Reading Data Sequentially from a Random-Access File Example: A Transaction-Processing Program Input/Output of Objects Introduction Storage of data Arrays, variables are temporary Files are permanent Magnetic disk, optical disk, tapes In this chapter Create, update, process files Sequential and random access Formatted and raw processing The Data Hierarchy From smallest to largest Bit (binary digit) 1 or 0 Everything in computer ultimately represented as bits Cumbersome for humans to use Character set Digits, letters, symbols used to represent data Every character represented by 1's and 0's Byte: 8 bits Can store a . | Chapter 14 - File Processing Outline Introduction The Data Hierarchy Files and Streams Creating a Sequential-Access File Reading Data from a Sequential-Access File Updating Sequential-Access Files Random-Access Files Creating a Random-Access File Writing Data Randomly to a Random-Access File Reading Data Sequentially from a Random-Access File Example: A Transaction-Processing Program Input/Output of Objects Introduction Storage of data Arrays, variables are temporary Files are permanent Magnetic disk, optical disk, tapes In this chapter Create, update, process files Sequential and random access Formatted and raw processing The Data Hierarchy From smallest to largest Bit (binary digit) 1 or 0 Everything in computer ultimately represented as bits Cumbersome for humans to use Character set Digits, letters, symbols used to represent data Every character represented by 1's and 0's Byte: 8 bits Can store a character (char) Also Unicode for large character sets (wchar_t) The Data Hierarchy From smallest to largest (continued) Field: group of characters with some meaning Your name Record: group of related fields struct or class in C++ In payroll system, could be name, SS#, address, wage Each field associated with same employee Record key: field used to uniquely identify record File: group of related records Payroll for entire company Sequential file: records stored by key Database: group of related files Payroll, accounts-receivable, inventory The Data Hierarchy 1 01001010 Judy Judy Green Sally Black Tom Blue Judy Green Iris Orange Randy Red File Record Field Byte (ASCII character J) Bit Files and Streams C++ views file as sequence of bytes Ends with end-of-file marker When file opened Object created, stream associated with it cin, cout, etc. created when included Communication between program and file/device 0 3 1 2 4 5 8 9 . . n-1 end-of-file marker
đang nạp các trang xem trước