Unformatted I/O Operations in C++

Unformatted I/O Operations are used for performing input/output operations at the console and the resulting data is left unformatted.

Overloaded Operators>>and<<

We have used the objects cin and cout for the input and output of data of various types. The >> operator is overloaded in the istream class and << is overloaded in the ostream class. It has the following syntax:


put() and get() functions:

The classes istream and ostream define two member functions get() and put() is used to handle the single character input/output operations. There are two types of get() functions. We can use both get(char*) and get(void) prototype to fetch a character including the blank space, tab and the newline character. The get(char*) version assigns the input character to its argument and the get(void) version returns the input character.


char c;
cin.get(c);  // get a character from keyboard and assign it to c
 cin.get(c);  // get another character