Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to express the format controller (placeholder) of short integer variables and unsigned short integer variables in VC++6.0?
How to express the format controller (placeholder) of short integer variables and unsigned short integer variables in VC++6.0?
Iomanip.h is an I/O flow control header file, just like the print format in C language.

Decimal radix 10 is equivalent to "%d"

Hexadecimal radix 16 is equivalent to "%X"

Decimal base 8 is equivalent to "%o"

Setfill(c) sets the fill character to c.

Setprecision(n) sets the display decimal precision to n digits.

The field width of Setw(n) is n characters.

Setiolags (IOs:: fixed: fixed) fixed floating-point display.

Setiolags (IOS:: Scientific) index representation

Setiosflags(ios::left) left alignment

Setiosflags(ios::right) right alignment

Setiosflags(ios::skipws ignores leading spaces.

Setiosflags (IOS:: uppercase) 16 hexadecimal number uppercase output.

Setiosflags (IOs:: lowercase) 16 hexadecimal lowercase output.

Setiosflags(ios::showpoint) forces the decimal point to be displayed.

Setiosflags(ios::showpos) forces the display of symbols.

////////////////////////////////////////////////////

Here is an example.

# include & ltiostream.h & gt

# include & ltiomanip & gt

#pragma argsused

int main(int argc,char* argv[])

{

int num 1;

Unsigned integer num2

num 1 = 28;

num 2 = 4345 1;

cout & lt& ltsetw(5)& lt; & ltnum 1 & lt; & ltendl//setw(5) Set the domain width to 5 characters.

cout & lt& ltsetw(5)& lt; & ltnum2 & lt& ltendl//setw(5) Set the field width to 5 characters.

cout & lt& ltsetw(5)& lt; & ltset fill(' # ')& lt; & ltnum 1 & lt; The & ltendl// field is 5 characters wide, which is not enough to be filled with "#".

cout & lt& ltsetw(5)& lt; The & ltnum2 & lt& ltendl// field has a width of 5 characters.

Returns 0;

}

Results:

28

4345 1

###28

4345 1