3. Hello!
I am Vaishnai
I am here because I love to give
presentations.
You can find me at @vaishnavi.in
3
4. CONTENTS
• Introduction to Manipulators
• Types of Manipulators
• Input manipulators
• Output Manipulators
• Parameterized manipulators
4
5. INTRODUCTION
• Manipulators are operators that are used to format the data display .
• It is mainly used for make-up the program.
• Manipulators functions are special stream function that changes certain
characteristics of the input and output .
• To carry out the operations of the manipulators functions in user program, the
header file input and output manipulator<iomanip.h> must be included.
• Manipulators are the functions specially designed to be used in conjunction with
insertion (<<) and extraction (>>) operator on stream object.
e.g.- cout<<boolalpha;
• Manipulators are used to change formatting parameters on streams and to insert
or extract certain special characters.
7. • Ws-The manipulator function ws stands for white space. It is used to ignore the
leading white space that precedes the first field.
INPUT MANIPULATORS
.
7
8. OUTPUT MANIPULATORS
i. Endl- The endl is an an output manipulator to generate a carriage return or
linefeed character. The endl may be used several times in a c++ statement.
Write a newline ('n') and flush buffer.
ii. Ends-The ends is a manipulator used to attach a null terminator(‘0’) at the end
of a string.
The ends manipulator takes no argument whenever it is invoked.
This causes a null character to the output.
.
.
8
9. Continued…
iii. Flush -The flush member function is used to cause the stream associated with
the output to be completely emptied.
This argument function takes no input parameter whenever it is invoked.
In case of a disk file being copied to another ,it has to flush the output
buffer prior to rewinding the output file for continued use .
Flush() does not have anything to do with flushing the input buffer.
9
10. PARAMETRIZEDMANIPULATORS
i. Setiosflag- The setiosflag manipulator function is used to control different input
and output settings. The IO stream maintains a collection of flag bits.
The setiosflag manipulators performs the same function as the setf
function.
SYNTAX-setiosflag(long f)
ii. Resetioflags- It performs the same functions as that of the resetf function .
flag represented by the set bits in f are reset.
SYNTAX-Resetioflags(long f)
10
11. Continued….
• Setw()-The setw() stands for the ‘setwidth’.
The setw() manipulators is used to specify the minimum no. of character
position on the output field a variable will consume.
SYNTAX-setw (int w)
setw(int w) changes the field width to w , but only for the new insertion.
the default width is 0.
Between the data variables in c ++ space will not be inserted automatic
-ally by the compiler .It is upto programmer to introduce proper spaces
among data while displaying onto screen.
11
12. Continued….
• Setfill()-To Setfill() manipulator function is used to specify a different character to
fill the unused field width of the value.
The default fill character is a space.
SYNTAX-Setfill(char f)
12
13. Continued….
• Setbase()- Setbase field flag; Sets the base-field to one of its possible values:
decimal, hexadecimal or octal according to argument base.
13
std::Setbase (int base);
decimal : if base is 10
hexadecimal : if base is 16
octal : if base is 8
zero : if base is any other value.
14. Continued….
• Setprecision-It is used to control the no. of digits of an output stream display of a
floating point value .
SYNTAX-Setprecision(int p)
which set precision for floating point insertion to p.
The default precision is 6.
14