软件设计(II)教学课件:Chapter10 Console IO Operations.pptVIP

  • 3
  • 0
  • 约1.03万字
  • 约 30页
  • 2021-11-30 发布于安徽
  • 举报

软件设计(II)教学课件:Chapter10 Console IO Operations.ppt

Review Questions Null. * Chapter 10 Console I/O Operations §10.1 C++ Stream C++ Stream Classes §10.2 Unformatted I/O Operations §10.3 Formatted Console I/O Operations §10.4 Managing Output with Manipulators * Input and Output? How to provide the input data present results? cin and cout How to control the format of input and output? C++ supports a rich set of I/O functions and operations C++ supports all of C’s rich set of I/O functions These functions and operations use the advanced features of C++: classes, inheritance, polymorphism Using stream and stream classes to implement its I/O operations with the console (this chapter), and with disk files(next chapter). * §10.1 C++ Stream Stream: an interface to operate on different I/O systems Display/terminals, hard disks, flash disks, etc… Independent of the actual device A stream is a sequence of bytes A program extracts the bytes from an input stream and inserts bytes into an output stream Input device Output device Program Output stream Input stream Extract Insert About C++ Stream A C++ program handles data (input/output) independent of the devices used. The data in the input stream can come from the keyboard or any other storage device. The data in the output can go to the screen or any other storage device : * The cin/cout stream Pre-defined streams Automatically opened when a program begins its execution. Standard input/output stream Connected to the standard input/output devices Usually the keyboard/screen. Can redirect streams to other devices or files freopen(test.txt, r, stdin); freopen(test.txt, w, stdout); cout“Test it.”endl; C++ Stream Classes Stream classes for console I/O operations: These classes are declared in the header file iostream: Eg: include iostream ios is declared as the virtual base class ios ostream istream streambuf iostream istream_withassign ostream_withassign iostream_withassign cin cout get(), read(), getline() overloading put(), write() overloading §10.2 Unformatted I/O

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档