Chp~16 - C PROGRAMMING Chapter 16 Streams Overview of...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ PROGRAMMING Chapter 16 Streams , Overview of Streams Encapsulation , Figure 16.1. , Buffering Figure 16.2. , Figure 16.3. , Figure 16.4. , Figure 16.5. Streams and Buffers , Standard I/O Objects , Redirection Input Using cin Listing 16.1. cin handles different data types . Strings , String Problems Listing 16.2. Trying to write more than one word to cin . Listing 16.3. Multiple input . operator>> Returns a Reference to an istream Object Other Member Functions of cin Single Character Input Listing 16.4. Using get() with no parameters. Listing 16.5 Using get() with parameters. Getting Strings from Standard Input Listing 16.6. Using get() with a character array Listing 16.7. Using getline(). Using cin.ignore() Listing 16.8. Using ignore(). peek() and putback() Listing 16.9. Using peek() and putback(). Output with cout Flushing the Output Related Functions Listing 16.10. Using put(). , Listing 16.11. Using write(). Manipulators, Flags, and Formatting Instructions Using cout.width() Listing 16.12. Adjusting the width of output. , Setting the Fill Characters Listing 16.13. Using fill() . , Set Flags Listing 16.14. Using setf. , Streams Versus the printf() Function Listing 16.15. Printing with printf(). File Input and Output , ofstream , Condition States Opening Files for Input and Output Listing 16.16. Opening files for read and write . Changing the Default Behavior of ofstream on Open Listing 16.17. Appending to the end of a file Binary Versus Text Files , Listing 16.18. Writing a class to a file . Command-Line Processing Listing 16.19. Using command-line arguments . Listing 16.20. Using command-line arguments. Summary , Q&A , Quiz , Exercises
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Chapter 16 Streams Until now, you've been using cout to write to the screen and cin to read from the keyboard, without a full understanding of how they work. ToChapter, you will learn What streams are and how they are used. How to manage input and output using streams. How to write to and read from files using streams. Overview of Streams C++ does not, as part of the language, define how data is written to the screen or to a file, nor how data is read into a program. These are clearly essential parts of working with C++, however, and the standard C++ library now includes the iostream library, which facilitates input and output (I/O). The advantage of having the input and output kept apart from the language and handled in libraries is that it is easier to make the language "platform-independent." That is, you can write C++ programs on a PC and then recompile them and run them on a Sun Workstation. The compiler manufacturer just supplies the right library, and everything works. At least that's the theory. NOTE: A library is a collection of OBJ files that can be linked to your program to provide additional functionality. This is the most basic form of code reuse, and has been around since ancient programmers chiseled 1s and 0s into the walls of caves.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern