Basic I/O

suggest change

#search cin, cout, cerr, clog

The standard library <iostream> defines few streams for input and output:

|stream | description                      |
|-------|----------------------------------|
|cin    | standard input stream            |
|cout   | standard output stream           |
|cerr   | standard error (output) stream   |
|clog   | standard logging (output) stream |

Out of four streams mentioned above cin is basically used for user input and other three are used for outputting the data. In general or in most coding environments cin (console input or standard input) is keyboard and cout (console output or standard output) is monitor.

cin >> value

cin   - input stream
'>>'  - extraction operator
value - variable (destination)

cin here extracts the input entered by the user and feeds in variable value. The value is extracted only after user presses ENTER key.

cout << "Enter a value: "

cout              - output stream
'<<'              - insertion operator
"Enter a value: " - string to be displayed

cout here takes the string to be displayed and inserts it to standard output or monitor

All four streams are located in standard namespace std so we need to print std::stream for stream stream to use it.

There is also a manipulator std::endl in code. It can be used only with output streams. It inserts end of line '\n' character in the stream and flushes it. It causes immediately producing output.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Basic I/O:

Table Of Contents
8 Arrays
11 Loops
37 Basic I/O
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype