.

Basic Input And Output Function in C++

C++ provides the library function to perform several ways of input and output. The input and output is performed in the sequence of bytes called as streams. There are input stream and output stream.

I/O Library Header Files

Input Stream – the data flows from device to main memory then it is called input.

Output Stream – the data flows from main memory to the device is called output.

Example

The Standard Output Stream(cout)

The standard output displays the output of the program. Cout is the instance that produces ostream. The data need to display the screen inserted using cin operation.

Example

The Standard Input Stream (cin)

The input will given through the device is the keyboard. The input can be read and the data is given to the process for performing the task. The extraction operation extracts the data present in the object cin entered through keyboard.

Example

The Standard Error Stream (cerr)

This is the standard error stream which is used for obtaining the error of the output. This is also termed as ostream errors. Cerr is unbuffered to display the error message.

Example

The Standard Log Stream (clog)

This is also ostream classNamewhich is used to display errors but cerr is inserted in the buffer and is stored until the buffer is not filled completely. The error message will be displayed in the screen.

Example

.