This chapter covers:
- Reading from keyboard and writing to screen
- Standard input, output, error streams
- Formatting numbers and text
- Writing data to files on disk
One of the pillars of every useful program is its input and output (I/O). Almost every program reads some input data from keyboard, file, or network, does some calculation or processing on it, and outputs the result to the screen, file on disk, or some other device. If the program is designed to be used directly by a human user (rather than being a piece of some intricate pipeline), I/O becomes even more important. Specifically, inputting data to the program should be as easy as possible, with minimum effort for the user. The output should be easy to parse and not surprising. Some of the best end-user software out there is intuitive on the first try, without the need to refer to dense user manuals.