📄 iomanip.html
字号:
<HTML><HEAD><TITLE><iomanip></TITLE></HEAD><BODY><H1><A NAME="<iomanip>"><CODE><iomanip></CODE></A></H1><HR><P>Include the <A HREF="lib_cpp.html#iostreams">iostreams</A>standard header <B><CODE><iomanip></CODE></B>to define several <A HREF="ios.html#manipulators">manipulators</A>that each take a single argument. Each of these manipulators returnsan unspecified type, called <CODE>T1</CODE> through <CODE>T6</CODE>here, that overloads both<CODE>istream::<A HREF="istream.html#istream::operator>>">operator>></A></CODE>and<CODE>ostream::<A HREF="ostream.html#ostream::operator<<">operator<<</A></CODE>.Thus, you can write extractors and inserters such as:</P><PRE>cin >> setbase(8);cout << setbase(8);</PRE><PRE> // DECLARATIONST1 <B><A HREF="#resetiosflags">resetiosflags</A></B>(ios_base::fmtflags mask);T2 <B><A HREF="#setiosflags">setiosflags</A></B>(ios_base::fmtflags mask);T3 <B><A HREF="#setbase">setbase</A></B>(int base);T4 <B><A HREF="#setfill">setfill</A></B>(char ch);T5 <B><A HREF="#setprecision">setprecision</A></B>(streamsize prec);T6 <B><A HREF="#setw">setw</A></B>(streamsize wide); // END OF DECLARATIONS</PRE><H2><A NAME="resetiosflags"><CODE>resetiosflags</CODE></A></H2><PRE>T1 <B>resetiosflags</B>(ios_base::fmtflags mask);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios_base::setf">setf</A>(ios_base::<A HREF="ios.html#ios_base::fmtflags">fmtflags</A>(), mask)</CODE>,then returns <CODE>str</CODE>.</P><H2><A NAME="setbase"><CODE>setbase</CODE></A></H2><PRE>T3 <B>setbase</B>(int base);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios_base::setf">setf</A>(mask,ios_base::<A HREF="ios.html#ios_base::basefield">basefield</A>)</CODE>,then returns <CODE>str</CODE>. Here, <CODE>mask</CODE> is determinedas follows:</P><UL><LI>If <CODE>base</CODE> is 8, then <CODE>mask</CODE> is<CODE>ios_base::<A HREF="ios.html#ios_base::oct">oct</A></CODE></LI><LI>If <CODE>base</CODE> is 10, then <CODE>mask</CODE> is<CODE>ios_base::<A HREF="ios.html#ios_base::dec">dec</A></CODE></LI><LI>If <CODE>base</CODE> is 16, then <CODE>mask</CODE> is<CODE>ios_base::<A HREF="ios.html#ios_base::hex">hex</A></CODE></LI><LI>If <CODE>base</CODE> is any other value, then <CODE>mask</CODE> is<CODE>ios_base::<A HREF="ios.html#ios_base::fmtflags">fmtflags</A>(0)</CODE></LI></UL><H2><A NAME="setfill"><CODE>setfill</CODE></A></H2><PRE>T4 <B>setfill</B>(char ch);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios::fill">fill</A>(ch)</CODE>,then returns <CODE>str</CODE>.</P><H2><A NAME="setiosflags"><CODE>setiosflags</CODE></A></H2><PRE>T2 <B>setiosflags</B>(ios_base::fmtflags mask);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios_base::setf">setf</A>(mask)</CODE>,then returns <CODE>str</CODE>.</P><H2><A NAME="setprecision"><CODE>setprecision</CODE></A></H2><PRE>T5 <B>setprecision</B>(streamsize prec);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios_base::precision">precision</A>(prec)</CODE>,then returns <CODE>str</CODE>.</P><H2><A NAME="setw"><CODE>setw</CODE></A></H2><PRE>T6 <B>setw</B>(streamsize wide);</PRE><P>The manipulator returns an object that, when extracted from orinserted into the stream <CODE>str</CODE>, calls<CODE>str.<A HREF="ios.html#ios_base::width">width</A>(wide)</CODE>,then returns <CODE>str</CODE>.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> © 1992-2002by P.J. Plauger. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -