Lesson 27. Using Streams for Input and Output
You have actually been using streams all through this book, starting with Lesson 1, “Getting Started,” in which you displayed “Hello World” on the screen using std::cout
. It’s time to give this part of C++ its due attention and learn streams from a practical point of view. In this lesson, you find out
• What streams are and how they are used
• How to write to and read from files using streams
• Useful C++ stream operations
Concept of Streams
You are developing a program that reads from the disk, writes data to the display, reads user input from the keyboard, and saves data on the disk. Wouldn’t it be useful if you could treat all read activities and write activities using similar patterns irrespective ...
Get Sams Teach Yourself C++ in One Hour a Day, Seventh Edition 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.