6.2 Streams
You have seen streams in examples many times, but rarely did their type appear because we used the predefined streams of the standard library:
-
std::cout of type std::ostream is used for standard output, usually to the console—that is, the screen. Or you can redirect the output to a file.
-
std::cin of type std::istream is used for standard input, usually from the keyboard or a redirected file.
-
std::cerr and std::clog are also output data streams of type std::ostream and usually end up on the screen, but you can redirect them to a file separately from std::cout.
For inputs and outputs of a normal program flow, you normally use std::cin and std::cout. Each output takes time, and a call has overhead, so std::cout is buffered: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access