The Iomanip is the I/O flow control header file, just like the formatted output in C. Here are some common: the DEC base is 10 equivalent to "%d" hex base 16 equivalent to "%x" Oct base 8 equivalent to "%o" Setfill (c) Set the fill character to Csetprecision (n) to display a decimal precision of n bits SETW (n) Set the field width to n characters setioflags (ios::fixed) fixed floating point display setioflags (ios::scientific) The exponent represents the Setiosflags (Ios::left) left-aligned setiosflags (ios::right) right-aligned setiosflags (IOS::SKIPWS ignores leading whitespace setiosflags (ios::uppercase ) 16 Decimal Capital Output setiosflags (ios::lowercase) 16 lowercase output setiosflags (ios::showpoint) force display of decimals Setiosflags (ios::showpos) force display symbols
Required header file:
#include <iostream> #include <iomanip>
function of SETW (n): Preset width
COUT<<SETW (6) <<12345<<endl;
Setfill (char c): If there is no unused width in the preset width, use the Set character C to fill
Cout<<setfill (' # ') <<SETW (6) <<12345<<endl;
Role of SetBase (n): Converting output data to N-binary
Cout<<setbase (2) <<255<<endl; Cout<<setbase (8) <<255<<endl; Cout<<setbase (<<255<<endl;)
Setprecision (): Controls the output stream to display the number of floating-point numbers. C + + default stream output numeric value bit is 6
If Setprecision (n) is combined with setiosflags (ios::fixed), you can control the number of digits to the right of the decimal point. Setiosflags (ios::fixed) is a fixed-point representation of real numbers. If combined with setiosflags (ios::scientific), you can control the number of decimal digits of exponential notation. Setiosflags (ios::scientific) is an exponential representation of real numbers.
Cout<<setiosflags (ios::fixed) <<setprecision (8) <<25.376<<endl;
In the output with floating-point representation, Setprecision (n) represents the number of significant digits.
A detailed description of C + + formatted output functions