8. Files: Electronic Storage

Most practical applications (reservation systems, database systems, spreadsheets, and even games) store and retrieve persistent information. This is data that hangs around after the program ends and even after the computer is turned off.

Main memory (RAM) is not persistent. As soon as the computer is turned off, data in memory is lost forever. But even if main memory were more permanent—even if it didn’t zero out when the computer shuts down—main memory is too precious a resource to be dedicated to long-term record storage.

So when you need a place to put data for later use, put it in a disk file.

Introducing File-Stream Objects

In using cin and cout (console input and output), you’ve already made use of objects. ...

Get C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Second 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.