Presentation is loading. Please wait.

Presentation is loading. Please wait.

IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch.

Similar presentations


Presentation on theme: "IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch."— Presentation transcript:

1 IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch

2 cin & cout Standard in Standard out Standard error
Where input comes into a program by default Normally the keyboard Can be modified (e.g. pipes in UNIX) Standard out Where output is sent Normally the screen Can be modified (e.g. pipes) Standard error Where error messages are sent Frequently set to a file cin cout cerr clog Standard in Standard out Standard err buffered error Keyboard Monitor Default: Same as cout Default: Same as cerr Apparently, clog is the same as cerr, just buffered. Example: $ ./prgm [ARGS] 0<IN 1>OUT 2>ERR

3 Input and Output (IO or I/O)
Program Output

4 Input and Output (IO or I/O)
data source: input library input device device driver our program data destination: output library device driver output device

5 The Stream Model An ostream Values of various types
‘c’ “somewhere” ostream 1.234 Values of various types 123 buffer An ostream turns values of various types into character sequences sends those characters somewhere (console, file, main memory, another computer…)

6 The Stream Model An istream Values of various types
‘c’ “somewhere” istream 1.234 Values of various types 123 buffer An istream gets characters from somewhere (console, file, main memory, another computer,…) turns character sequences into values of various types

7 The Stream Model Supports reading and writing of typed entities
<< (output) and >> (input/extraction) plus other operations type-safe formatted typically stored as text but not necessarily, e.g, binary streams extensible define your own I/O operations for your own types a stream can be attached to any I/O or storage device

8 Many different Streams
What applies to cout/cin will also apply to file streams string streams Etc.

9 Model


Download ppt "IO Overview CSCE 121 Strongly influenced by slides created by Bjarne Stroustrup and Jennifer Welch."

Similar presentations


Ads by Google