4. Input, Output, and Files

If you aren’t tired by now of having to edit, resave, recompile, and rerun your applications every time you change the value of a variable, then you have more patience than we do. Any program or programming language is of limited use if it could only work with predefined values. This is why there are always ways in which you can work with data from external sources.

For starters, the most important concept to learn is how to take input from the keyboard. This will allow your programs to interact with a user. We begin this chapter by demonstrating how to take single-character, numeric, whole-word, and whole-line input. In the process of picking up these techniques, you also see how to ignore unnecessary input and take ...

Get C++ Programming: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.