Skip to main content

What is manipulator in C++?


Answer: Manipulators are special functions that can be included in the I/O statement to alter the format parameters of a stream. Table-2 shows some important manipulator functions that are frequently used. To access these manipulators, the file <iomanip.h> should be included in program.

                             
Table-2
              Manipulators                                                    Equivalent ios function
              setw( )                                                                  width( )
              setprecision( )                                                  precision( )
              setfill( )                                                                                fill( )
              setiosflags( )                                                      setf( )   
              resetioflags( )                                                   unsetf( )


              In addition to these functions supported by the C++ library, we can create our own manipulator functions to provide any special output formats. The following sections will provide details of how to use the pre-defined formatting and how to create new ones.

Comments