tailieunhanh - Lecture Programming principles and practice using C++: Chapter 10 - Bjarne Stroustrup

We get data from files, sensors, web connections, etc., which we want to analyze, print, graph, etc. Sometimes, we want to produce such data. In this lecture, we look at C++’s basic mechanisms for reading and writing streams of data. We also discuss an interesting – apparently trivial – problem: how to read an integer. | Chapter 10 Input/Output Streams Bjarne Stroustrup Abstract We get data from files, sensors, web connections, etc., which we want to analyze, print, graph, etc. Sometimes, we want to produce such data. In this lecture, we look at C++’s basic mechanisms for reading and writing streams of data. We also discuss an interesting – apparently trivial – problem: how to read an integer. Stroustrup/Programming/2015 Overview Fundamental I/O concepts Files Opening Reading and writing streams I/O errors Reading a single integer Stroustrup/Programming/2015 Input and Output input device device driver input library our program output library device driver output device data source: data destination: Stroustrup/Programming/2015 The stream model An ostream turns values of various types into character sequences sends those characters somewhere ., console, file, main memory, another computer c (1,234) 123 ostream buffer “somewhere” . | Chapter 10 Input/Output Streams Bjarne Stroustrup Abstract We get data from files, sensors, web connections, etc., which we want to analyze, print, graph, etc. Sometimes, we want to produce such data. In this lecture, we look at C++’s basic mechanisms for reading and writing streams of data. We also discuss an interesting – apparently trivial – problem: how to read an integer. Stroustrup/Programming/2015 Overview Fundamental I/O concepts Files Opening Reading and writing streams I/O errors Reading a single integer Stroustrup/Programming/2015 Input and Output input device device driver input library our program output library device driver output device data source: data destination: Stroustrup/Programming/2015 The stream model An ostream turns values of various types into character sequences sends those characters somewhere ., console, file, main memory, another computer c (1,234) 123 ostream buffer “somewhere” Stroustrup/Programming/2015 The stream model An istream turns character sequences into values of various types gets those characters from somewhere ., console, file, main memory, another computer c (1,234) 123 istream buffer “somewhere” Stroustrup/Programming/2015 The stream model Reading and writing Of typed entities > (input) plus other operations Type safe Formatted Typically stored (entered, printed, etc.) as text But not necessarily (see binary streams in chapter 11) Extensible You can define your own I/O operations for your own types A stream can be attached to any I/O or storage device Stroustrup/Programming/2015 Files We turn our computers on and off The contents of our main memory is transient We like to keep our data So we keep what we want to preserve on disks and similar permanent storage A file is a sequence of bytes stored in permanent storage A file has a name The data on a file has a format We can read/write a file if we know its name and

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.