This document discusses C++ input/output manipulators. It introduces manipulators as instructions that modify output streams. There are two types - non-argument manipulators like endl, and argument manipulators like setw() and setfill(). Endl not only moves to a new line but flushes the output buffer. Setw() sets a minimum field width for output, and setfill() fills any unused space in that field with a specified character. Sample programs demonstrate using these manipulators.
2. Introduction
Manipulators are instructions to the output stream
that modify the output in various ways.
They are of two types one taking arguments and
other without arguments
Non-argument manipulators Eg. Endl
Argumented manipulators Eg. Setw(),setfill()
Compiled By: Kamal Acharya
3. Endl
Its function is the same as the “n” in C.
More then that it not only transfer the control to the
new line but also flush the output buffer.
Compiled By: Kamal Acharya
4. Setw()
This manipulator sets the minimum field width on
output
SYNTAX:
Setw(x);
It causes the number or string that follows to be printed within
the field x.
The header file <iomanip.h> should be included while using it.
The content is right justified
For left justification –x should be used
Compiled By: Kamal Acharya
6. Setfill()
This is used after setw() manipulator.
It fills up the unused field assigned by the setw()
manipulators with the character passed as argument
to it.
SYNTAX:
Setfill(‘$’);
Compiled By: Kamal Acharya