LEC14-Streams-1 - 1 COEN 243 WINTER 2007 Instructor Dr...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 LECTURE 14 Introduction to C++ Stream Input/Output Instructor: Dr. Abdelwahab Hamou-Lhadj COEN 243 WINTER 2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 STREAMS Stream: sequence of bytes Input: from device (keyboard, disk drive) to memory Output: from memory to device (monitor, printer, etc.) I/O operations often bottleneck Wait for disk drive/keyboard input Low-level I/O Unformatted (not convenient for people) Byte-by-byte transfer High-speed, high-volume transfers High-level I/O Formatted Bytes grouped (into integers, characters, strings, etc.) Good for most I/O needs
Background image of page 2
3 Classic Streams vs. Standard  Streams Classic streams Input/output char s (one byte) Limited number of characters (ASCII) Standard stream libraries Some languages need special alphabets Unicode character set supports this wchar_t character type Can do I/O with Unicode characters
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 iostream Library Header Files iostream library Has header files with hundreds of I/O capabilities <iostream> Standard input ( cin ) Standard output ( cout ) Unbuffered error ( cerr ) Buffered error ( clog ) <iomanip> Formatted I/O with parameterized stream manipulators <fstream> File processing operations
Background image of page 4
5 Stream Input/Output Classes  and Objects << and >> Stream insertion and extraction operators cin istream object Connected to standard input (usually keyboard) cin >> grade; Compiler determines data type of grade
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Stream Input/Output Classes  and Objects cout ostream object Standard output (usually display screen) cin << grade; As with cin , no type information needed cerr , clog ostream objects Connected to standard error device cerr outputs immediately clog buffers output Outputs when buffer full or flushed Performance advantage (discussed in OS classes)
Background image of page 6
7 Character Output using  Member Function put put function Outputs characters cout.put( 'A' ); May be cascaded
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

LEC14-Streams-1 - 1 COEN 243 WINTER 2007 Instructor Dr...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online