CS106L Lecture 1 Streams

What is 1. Streams

In general, we need to write the program and some external devices (external devices) to interact (data transfer, etc.). Typically, these external devices comprising: console & keyboard, files, other programs (by pipelines), sockets (through networking). CS106L, the interaction of two former major concern, for example, to print a date object to the console, or read from a file such as a digital.

The above-described interaction can be divided into two parts:
1. Reading and writing process: External Source <-> String representation
2. Type conversion process: string representation <-> other type

Stream: a program outside world and the most basic unit of interaction. To provide a unified and interactive interface to external source, you can think of Stream becoming a character buffer, use this character buffer source interact with the external.
source ---- stream ----> destination

2. Why is it called stream

stream means that no one-time read and write all data is often the case, a part of each read and write, for example, reading a file can be read line by line, a character may be a character reading, and the like. This stream is very flexible in the reader.

Example 3. stream

cout (for character output) is connected to the source stream one kind of console console

Guess you like

Origin www.cnblogs.com/isguoqiang/p/11601247.html