Overview
Chapter 3 explores I/O operations in more detail. Students will learn how I/O statements
extract input from the standard input device and send output to the standard output
device. They will become more familiar with using predefined functions and learn
about several manipulators that are used to format output. Finally, students will enhance
their knowledge of I/O by extending the operations associated with standard
input/output devices to files.
Objectives
In this chapter, the student will:
• Learn what a stream is and examine input and output streams
• Explore how to read data from the standard input device
• Learn how to use predefined functions in a program
• Explore how to use the input stream functions get, ignore, putback, and peek
• Become familiar with input failure
• Learn how to write data to the standard output device
• Discover how to use manipulators in a program to format output
• Learn how to perform input and output operations with the string data type
• Learn how to debug logic errors
• Become familiar with file input and output
Teaching Tips
I/O Streams and Standard I/O Devices
1. Review the three major operations a program performs: get data, manipulate data, and
3. Introduce the concept of an I/O stream as a sequence of bytes from a source to a
destination. Define the terms input and output stream, and the terms common input and
common output.
You might set aside some extra time to discuss streams, as they may be a new
concept for some students. Draw an analogy to how traffic travels across a
network as a sequence of bytes.