Stream Input/Output Flashcards
Where does I/O occur?
In streams
What is a stream?
A sequence of bytes
Low level I/O
Device to memory
High level I/O
Bytes grouped into units (ex: integers, strings)
Unformatted vs formatted I/O
Unformatted is faster but difficult to use
Formatted requires extra processing time but is readable
How to declare all stream I/O operations?
<iostream>
</iostream>
How to declare parameterized stream manipulators?
<iomanip>
</iomanip>
basic_istream and basic_ostream
Templates for input and output respectively
Template that supports both input and output?
basic_iostream
istream object cin tied to….
standard input device (keyboard)
ostream cout tied to….
Standard output device (screen)
Unbuffered ostream output?
cerr
Buffered ostream output
clog
How are data types determined for input and output?
Automatically by compiler
How are addresses displayed?
Hexadecimal
How can you print the address in a pointer variable?
Cast pointer to void*
What member function outputs one character and can be cascaded?
put
Properties of stream input stream extraction operator»_space;
Automatically skips white space characters
Returns false after end of file encountered
How to input series of values using stream extraction operation?
In a while looo
Which member function inputs one character and returns character or EOF at end of file?
get
What function reads line of string but removes the delimiter and does not store
getline
How to skip specified number of characters in an input stream?
ignore member function
How to place previous character obtained by get on a stream back into stream
putback
Which function returns next character from input stream but does not extract from the stream?
peek
What is type-safe I/O
Throws error when «_space;» has not been overloaded for a user defined type
Which member functions input or output bytes to or from memory?
read and write
Member function that returns number of characters input by previous read operation on stream
gcount
If read inputs specified number of characters into character array, what is set if fewer than specified number are read?
failbit
How to set a base to hexadecimal, octal, or decimal until declared otherwise?
Use hex, oct, and dec
Which parameterized stream manipulator sets the base for integer output?
setbase
Takes integer argument of 10, 8, or 16
How can floating point precision be controlled?
precision member function
Sticky
How to set field width and return previous width? How long is it applicable?
width or setw
Only applies for the next insertion or extraction
How is setw different than width?
Breaks larger lines into chunks of that size
Can you create your own stream manipulators?
Yes
How to force floating point number to be output with decimal point?
showpoint stream manipulator
Which stream manipulators left and right justify with padded characters?
left and right
Which stream manipulator can indicate number’s sign or base be left justified while magnitude is right justified?
internal
How to specify fill character?
setfill or fill
How to force base to be output?
showbase
How to output floating point number in scientific format?
scientific
How to output X for hexadecimals or E for scientific values?
uppercase