/* related posts with thumb nails */

IOS Formatting Flags:


Flag
Meaning
skipws
Skips white spaces
showbase
Shows base indicator i.e. 0 for octal 0x for hexadecimal
showpoint
Shows decimal point and zeros after for float value
showpos
Shows “+” 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


4   To set ios flags, we use the function “setf”
4   To reset ios flags, we use the function “unsetf”

Example:
main()
{
char x[]=“hello”;
cout.fill(‘*’);
cout.width(10);
cout.setf(ios::left);
cout<<x;           // prints “hello*****”

float f=34.56;
cout.setf(ios::scientific);           
cout<<f;           // prints 3.456e+01
}
Related Topics:

0 comments:

Post a Comment