C++语言程序设计

下表中列出了ios中控制流格式的成员函数：

| 表12-6

Flags | 设置或读取流的格式标志
Setf | 操纵流的格式标志
Unsetf | 清除流的格式标志
Fill | 设置或读取流的填充字符
Precision | 设置或读取流的浮点数显示精度
Width | 设置或读取流的输出宽度

ios类中定义的格式标志：

| 程序12-8

// formatting flags
enum {
skipws = 0x0001, // skip whitespace on input
left = 0x0002, // left-adjust output
right = 0x0004, // right-adjust output
internal = 0x0008, // padding after sign or base indicator
dec = 0x0010, // decimal conversion
oct = 0x0020, // octal conversion
hex = 0x0040, // hexadecimal conversion
showbase = 0x0080, // use base indicator on output
showpoint = 0x0100, // force decimal point (floating output)
uppercase = 0x0200, // upper-case hex output
showpos = 0x0400, // add '+' to positive integers
scientific= 0x0800, // use 1.2345E2 floating notation
fixed = 0x1000, // use 123.45 floating notation
unitbuf = 0x2000, // flush all streams after insertion
stdio = 0x4000 // flush stdout, stderr after insertion
};

iostream中预定义的操纵算子：

| 程序12-9

/*
* Manipulators
*/
ostream _FAR & _Cdecl endl(ostream _FAR &);
//insert newline and flush
ostream _FAR & _Cdecl ends(ostream _FAR &);
//insert null to terminate string
ostream _FAR & _Cdecl flush(ostream _FAR &);
//flush the ostream
ios _FAR & _Cdecl dec(ios _FAR &);
//set conversion base to decimal
ios _FAR & _Cdecl hex(ios _FAR &);
//set conversion base to hexadecimal
ios _FAR & _Cdecl oct(ios _FAR &);
//set conversion base to octal
istream _FAR & _Cdecl ws(istream _FAR &);
//extract whitespace characters