Coupon Accepted Successfully!


Streams in C++ and Stream Classes

The C++ supports a number of I/O operations to perform read and write operations. These C++ I/O functions help the user to work with different types of devices such as keyboard, disk, tape drivers, etc. Stream is an inter-mediator between I/O devices and the user. The standard C++ library contains the I/O stream functions. The I/O functions are part of the standard library that provides portability to the language itself. A library is a set of .obj files connected to the user’s program.

The stream is a flow of data, measured in bytes, in sequence. If data is received from input devices in sequence, then it is called as source stream, and when the data is passed to output devices, then it is called as destination stream. This process of flow of data is also known as encapsulation through streams. The data is received from the keyboard or disk and can be passed to the monitor or to the disk. Figure describes the concept of stream with input and output devices.

The data in source stream can be used as input data by the program. So, the source stream is also called as input stream. The destination stream that collects output data from the program is known as the output stream. The mechanism of the input and output stream is illustrated in Figure.

As discussed earlier, the stream is an inter-mediator between I/O devices and the user. The input stream receives data from keyboard or storage devices such as hard disk, floppy disk, etc. The data present in output stream is passed on to the output devices such as monitor or printer according to the user’s choice.

Streams and I/O devices

C++ input and output streams

Test Your Skills Now!
Take a Quiz now
Reviewer Name