Streams
What's a stream?
A stream is a "flow" of characters (or other kind of data).
- Input is delivered to your program from an input device by an input stream.
- Output is delivered from your program to an output device by an output stream.
- Your program is unaware of where the data comes from or where it goes.
(another instance of abstraction)
You've been using streams
Although we didn't call them streams, that's exactly what cin
and cout are.
- cin is an input stream "connected" to the keyboard
- cout is an output stream "connected" to the screen
- cin and cout are automatically available to you when your program starts
Later we'll talk about another stream, cerr that's also automatically
available
You can define your own streams that are "connected" to other input/output
devices, usually a file.
As we look at using streams to perform file input/output, notice that
it works just like we discussed when talking about cin and cout.
Last Modified: Monday, 28-Aug-2006 10:15:54 EDT