O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving the Tape Between Sessions

So far, all of the calculator's actions have been based on your input, and when you stop the calculator, all of the work you've entered into it has been lost. This is because program variables only retain their content while the program is running. Their collected content is often referred to as the program's state.

Most computers have a file system, whose purpose is to retain data between program runs. And every programming language has a way to put data into files in the file system and get data from them. C++ uses a special kind of stream—the fstream (file stream), which is similar to cin and cout—for that purpose.

fstreams

Unlike cin and cout, the file stream #include<fstream> does not provide variables representing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required