Introduction
Streams & Stream Classes
Unformatted Input Output Operations
Formatted Console Input Output Operation
Formatting Flags, Bit fields and setf()
Designing Our Own Manipulators
3.
Managing Console I/O Operations
INPUT & OUTPUT
C++ supports a rich set of I/O operations
C++ uses the concept of stream & stream
classes
4.
o A sequence of bytes
o An interface between program and device
INPUT EXTRACTION
STREAM FROM INPUT
INPUT STREAM
DEVICE
PROGRAM
OUTPUT
DEVICE
INSERTION
OUTPUT INTO OUTPUT
STREAM STREAM
5.
C++ containsa hierarchy of classes that are used to define
various streams
ios
INPUT OUTPUT
POINTER
istream streambuf ostream
iostream
Istream_withassign Iostream_withassign Ostream_withassign
6.
Overloaded operators >> and <<
get() and put() functions
getline() and write() functions
7.
C++ supports anumber of features which can
be used for formatting the output. These
features include :-
ios class functions
Manipulators
User-defined Manipulators
8.
FUNCTION TASK
Width() To specify the required field size for
displaying the output value
Precision() To specify the digits to be displayed
after decimal point of a float value
Fill() To specify a character that is used to
fill the unused portion of a field
Setf() To specify format flags that can
control the form of output display
Unsetf() To clear the flags specified
We havetaken all the basic ideas about the
concepts from the book “OBJECT ORIENTED
TECHNIQUES” – by E. Balagurusamy
Images are made in Ms- Paint
& every thing is accompanied by ideas of our
own
30.
The function ofistream class is to :
a) inherit the properties of ios
b) Declares input functions such as
get(), getline(), read() etc.
c) Contains overloaded extraction operator >>
d) All of the above
31.
The function ofstreambuf is to :
a) provides an interface to physical devices through buffers
b) Can’t act as a base for filebuf class used for ios files
c) Declares constants and functions that are necessary for
handling formatted i/p and o/p operations
d) None of the above
32.
A stream isa sequence of ___________.
a) Bytes
b) Files
c) Manipulators
d) None of the above
33.
Which are themember functions of ios class :
a) precision()
b) width()
c) fill()
d) All the above
34.
What will bethe output of following :
cout.fill(‘*’);
cout.precision(3);
cout.setf(ios::internal, ios::adjustfield);
cout.setf(ios::scientific, ios::floatfield);
cout.width(15);
cout<<-12.34567<<“n”;
-******1.235e+01 (.A B.) -*****1.235e+01
-*****.1235e+02
-*********1.236
(.C D.)
35.
a) The __________ operator is overloaded in the istream class
a) Insertion
b) >>
c) <<
d) None of the above
36.
Which Class isneeded to be virtual in this case :
a.) iostream
b.) ios
c.) istream or ostream
d.) no one is required
ios
INPUT OUTPUT
POINTER
istream streambuf ostream
iostream
Istream_withassign Iostream_withassign Ostream_withassign
37.
Q8.
The header fileiomanip can be used in place of
iostream ??
Q9.
programmer can’t define a manipulator that could
represent a set of formatted functions ??
38.
What is thedefault precision value ??
a.) 0 b.) 4
c.) 6 d.) 3