Chapter 12 ABSOLUTE C++ Streams and File I/O WALTER SAVITCH SECOND EDITION PEARSON Copyright2006 Pearson Addison-Wesley All rights reserved
Chapter 12 Streams and File I/O
Learning Objectives ◆l/O Streams ◆File I/O ◆Character I/O ◆Tools for Stream I/O ◆File names as input Formatting output,flag settings ◆Stream Hierarchies Preview of inheritance Random Access to Files Copyright 2006 Pearson Addison-Wesley.All rights reserved. 12-2
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 12-2 Learning Objectives ¨ I/O Streams ¨ File I/O ¨ Character I/O ¨ Tools for Stream I/O ¨ File names as input ¨ Formatting output, flag settings ¨ Stream Hierarchies ¨ Preview of inheritance ¨ Random Access to Files
Introduction ◆Streams ◆Special objects Deliver program input and output ◆File 1/o ◆Uses inheritance Not covered until chapter 14 +File 1/O very useful,so covered here Copyright006 Pearson Addison-Wesley.All rights reserved. 12-3
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 12-3 Introduction ¨ Streams ¨Special objects ¨Deliver program input and output ¨ File I/O ¨Uses inheritance ¨Not covered until chapter 14 ¨File I/O very useful, so covered here
Streams ◆A flow of characters ◆Input stream ◆Flow into program Can come from keyboard ◆Can come from file ◆Output stream ◆Flow out of program ◆Can go to screen ◆Can go to file Copyright 2006 Pearson Addison-Wesley.All rights reserved. 12-4
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 12-4 Streams ¨ A flow of characters ¨ Input stream ¨ Flow into program ¨ Can come from keyboard ¨ Can come from file ¨ Output stream ¨ Flow out of program ¨ Can go to screen ¨ Can go to file
Streams Usage We've used streams already ◆cin +Input stream object connected to keyboard ◆Cout Output stream object connected to screen Can define other streams ◆To or from files Used similarly as cin,cout Copyright006 Pearson Addison-Wesley.All rights reserved. 12-5
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 12-5 Streams Usage ¨ We’ve used streams already ¨cin ¨Input stream object connected to keyboard ¨cout ¨Output stream object connected to screen ¨ Can define other streams ¨To or from files ¨Used similarly as cin, cout