Formatted I/O Operations in C++

C++ supports a number of features that could be used for formatting the output. These features include:

  • ios class functions and flags
  • Manipulators
  • User-defined output functions

The ios class contains a large number of member functions that would help us to format the output in some ways.

width()It specifies the required field size for displaying an output value.
precision()It specifies the number of digits to be displayed after the decimal point of a float value.
fill()It specifies a character that is used to fill the unused portion of a field.
setf()It specifies format flags that can control the form of the output display.
unsetf()It is used to clear the flags specified.