Chapter 17. Input, Output, and Files

In this chapter you’ll learn about the following:

The C++ view of input and output

The iostream family of classes

Redirection

ostream class methods

Formatting output

istream class methods

Stream states

File I/O

• Using the ifstream class for input from files

• Using the ofstream class for output to files

• Using the fstream class file input and output

Command-line processing

Binary files

Random file access

Incore formatting

Discussing C++ input and output (I/O) poses a problem. On the one hand, practically every program uses input and output, and learning how to use them is one of the first tasks facing someone learning a computer language. On the other hand, C++ uses many of its ...

Get C++ Primer Plus, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.