Chapter 2

Writing with Output Streams

IN THIS CHAPTER

check Using the insertion operator

check Formatting your output generally and with flags

check Specifying precision and setting field widths

check Ensuring data safety with locked streams

Years ago, it was possible to have a personal computer with 3,000 bytes of memory. (Yes, that’s three thousand bytes, not 3MB.) As an option, this computer came with a floppy disk drive that sat outside it. It didn’t have a hard drive. Therefore, if you didn’t have a hard drive but you wanted to use an application, you had to load the application from a floppy, type its name, and press Enter!

Nowadays, the notion of a computer without permanent storage is unthinkable. Not only do your applications appear in permanent storage in the form of files, but your applications also create files to store in permanent storage. In this chapter, you see the different ways you can write to a file in any permanent storage location: hard drive, removable device, network, online, or wherever else permanent storage is found.

You don’t have to type the source code for this chapter ...

Get C++ All-in-One For Dummies, 4th 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.