Chapter 17 File processing 0 2018, SEU. All rights reserved. 1
© 2009, SEU. All rights reserved. © 2018, SEU. All rights reserved. 1 File Processing Chapter 17
Topics o 17.1 Introduction 17. 2 The Data Hierarchy 17.3 Files and streams 17. 4 Creating a sequential File o 17.5 Reading Data from a Sequential File o 17. 6 Input/Output of objects 0 2018, SEU. All rights reserved. 2
© 2009, SEU. All rights reserved. © 2018, SEU. All rights reserved. 2 Topics 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 Input/Output of Objects
17.1 Introduction 临时存储:变量和数组 永久存储:文件 °保存大量的数据 °存储在二级存储设备中 Magneticdisks Optical disks Tapes 0 2018, SEU. All rights reserved. 3
© 2009, SEU. All rights reserved. © 2018, SEU. All rights reserved. 3 17.1 Introduction 临时存储:变量和数组 永久存储:文件 保存大量的数据 存储在二级存储设备中 Magnetic disks Optical disks Tapes
大件的基本概念 本节中文件指的是磁盘文件。C++文件(fie)分为两类: 二进制文件和文本文件。 文本文件由字符序列组成,也称ASCT码文件,在文本文件 中存取的最小信息单位为字符( character) 二进制文件中存取的最小信息单位为字节(Byte),如bj C十+把每一个文件都看成一个有序的字节流,每一个文件 或者以文件结束符(EOF)结束,或者在特定的字节号处结束。 012345678 n-1 文件结束符 C++把文件看作有序的n个字节的流 0 2018, SEU. All rights reserved. 4
© 2009, SEU. All rights reserved. © 2018, SEU. All rights reserved. 4 本节中文件指的是磁盘文件。C++文件(file)分为两类: 二进制文件和文本文件。 文本文件由字符序列组成,也称ASCII码文件,在文本文件 中存取的最小信息单位为字符(character) 二进制文件中存取的最小信息单位为字节(Byte),如.obj C++把每一个文件都看成一个有序的字节流,每一个文件 或者以文件结束符(EOF)结束,或者在特定的字节号处结束。 0 1 2 3 4 5 6 7 8 … n-1 … 文件结束符 C++把文件看作有序的n个字节的流 文件的基本概念:
Topics o 17.1 Introduction o 17.2 The Data Hierarchy 17.3 Files and streams o 17.4 Creating a sequential File o 17.5 Reading Data from a Sequential File o 17. 6 Input/Output of objects 0 2018, SEU. All rights reserved. 5
© 2009, SEU. All rights reserved. © 2018, SEU. All rights reserved. 5 Topics 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 Input/Output of Objects