Home | Projects | Notes > C++ Programming > I/O & Streams

I/O & Streams

 

Overview

 

Files, Streams and I/O

 

io-streams

 

Common Header Files

Header FileDescription
iostreamProvides definitions for formatted input and output from/to streams
fstreamProvides definitions for formatted input and output from/to FILE streams
iomanipProvides definitions for manipulators used to format stream I/O

Commonly Used Stream Classes

ClassDescription
iosProvides basic support for formatted and unformatted I/O operations
(Base class for most other classes)
ifstreamProvides for high-level input operations on file based streams
ofstreamProvides for high-level output operations on file based streams
fstreamProvides for high-level I/O operations on file based streams
(Derived from ofstream and ifstream)
stringstreamProvides for high-level I/O operations on memory based strings
(Derived from istringstream and ostringstream)

Global Stream Objects

ObjectDescription
cinStandard input stream - by default 'connected' to the standard input device (i.e., keyboard).
Instance of istream.
coutStandard output stream - by default 'connected' to the standard input device (i.e., console).
Instance of ostream.
cerrStandard error stream - by default 'connected' to the standard error device (i.e., console).
Instance of ostream (unbuffered).
clogStandard error stream - by default 'connected' to the standard log device (i.e., console).
Instance of ostream (unbuffered).

 

Stream Manipulators

Boolean

Integer

Floating Point

Field Width, Align and Fill

Reading from a Text File

Input Files (fstream and ifstream)

Writing to a Text File

Output Files (fstream and ofstream)

Using String Streams