The input/output function of C++ works with different physical devices. It also acts as an interface between the user and the device.
A stream is a series of bytes and acts as source and destination for data. The source stream is called as input stream and the destination stream is called as output stream.
The cin, cout, cerr, and clog are pre-defined streams.
The header file iostream.h files must be #include when we use cin and cout functions.
The istream and ostream are derived class from ios base class. Figure 3.4 displays all the derived classes.
The formatting of output can be effectively done with member function of ios class. The member function width(), precision(), fill(), and setf() allows the user to design and display the output in formatted form.
Table 3.6 describes the list of functions without bit fields. These functions are also used for formatting the output
The putback() replaces the given character into the input stream. The member function ignore ignores the number of given character till it finds the termination character.
Manipulators also help the user in formatting the output. The programmer can also create his or her manipulators.
The header file iomanip.h contains pre-defined manipulators. Table 3.7 describes these manipulators.
Test Your Skills
Test Your Skills Now!
This is only a practice test, it is designed to help you revise your concepts
The test contains questions, only 1 option is correct for each question
This is a timed test.
After you have finished the test, press on the 'Finish Test' button to know your score and get the correct answers