Objectives : I/O streams

The iostream classes are used in both,  for buffered, formatted text I/O as well as  un-buffered  binary I/O. It is a core option left to the developer when they intend to use  the C/C++ libraries than the platform specified by the vendors like Visual C++.

The String and file streams would work in Windows OS, but the character-mode stream objects like cin, cout, cerr, and clog are inconsistent and out of place in the Windows graphical user interface. However, those stream objects, can be accommodated as a terminal/command window to interact with the keyboard.

I/OStream library

  • Manipulators:
  • Classes :
    •  filebuf,
    • fstream
    • ifstream
    • ios
    • ios_stream
    • istream
    • istringstream
    • ofstream
    • ostream
    • ostringstream
    • streambuf
    • stringbuf
    • stringstream
  • Objects:
    • cerr : error reporting
    • cin : get key board output
    • cout : display output on screen
  • types:

Streams and Buffers:

The input and out streams in C++ works like an envelope containing many heterogeneous classes . Most important fact of C++ streams is that, all the input and output are handled as a stream of bytes.

The objects like cin or cout are maneuvered by >> or << operations, respectively. The input operation with << operator basically inserts data from keyboard to an input stream; and the output operator ">>" load the data in the from of an output stream.

In the codes we use the syntaxes as shown in the following lines.

  • Input Operation : char ch1[200]; cin.getline(ch1, 200);
  • Output operation : cout<< "\n Hello World";

The object cout can further be used with many operations as shown below.

Step: 2 Click OK