4 System defined manipulator are defined in “iomanip.h”
4 These are defined by the system and can be directly used with stream operators.
Manipulator | Meaning |
skipws | Skips white spaces |
skipws | Does not skip white spaces on input |
showbase | Shows base indicator i.e. 0 for octal 0x for hexadecimal |
showpoint | Shows decimal point and zeros after for float value |
noshowpoint | Does not Show decimal point and zeros after for float value |
showpos | Shows “+” before positive integers |
noshowpos | Does not show “+” before positive integers |
dec | Convert to decimal |
oct | Convert to octal |
hex | Convert to hexadecimal |
left | Left justify output |
right | Right justify output |
scientific | Uses exponential format for float values |
endl | Inserts new line |
setw(n) | Sets width |
setfill(n) | Sets fill character |
setprecesion(n) | Sets floating point precesion |
setiosflags(flags) | Sets formatting flags |
resetiosflags(flags) | clears formatting flags |
Example:
main()
{
char x[]=“hello”;
cout<<setfill(‘*’)<<setw(10)<<left;
cout<<x; // prints “hello*****”
float f=3.456;
cout<<setprecesion(2);
cout<<endl<<f; // prints 3.46
int x=30;
cout<<endl<<oct<<x; // prints 36
}
0 comments:
Post a Comment