⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
  <div class="name-format">    putback  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  istream&amp; putback( char ch );</pre>  <p>The putback() function is used with input streams, and returns the  previously-read character <em>ch</em> to the input stream.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="peek.html">peek</a><br>    (Standard C I/O) <a href="../stdio/ungetc.html">ungetc</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    rdstate  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  iostate rdstate();</pre>  <p>The rdstate() function returns the <a href=  "../io_flags.html#state_flags">io stream state flag</a>s of the  current stream.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="bad.html">bad</a><br>    <a href="clear.html">clear</a><br>    <a href="eof.html">eof</a><br>    <a href="fail.html">fail</a><br>    <a href="good.html">good</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    read  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  istream&amp; read( char* buffer, streamsize num );</pre>  <p>The function read() is used with input streams, and reads  <em>num</em> bytes from the stream before placing them in  <em>buffer</em>. If <strong>EOF</strong> is encountered, read()  stops, leaving however many bytes it put into <em>buffer</em> as they  are.</p>  <p>For example:</p>  <pre class="example-code">   struct {     int height;     int width;   } rectangle;            input_file.read( (char *)(&amp;rectangle), sizeof(rectangle) );   if( input_file.bad() ) {     cerr &lt;&lt; &quot;Error reading data&quot; &lt;&lt; endl;     exit( 0 );   }            </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="gcount.html">gcount</a><br>    <a href="get.html">get</a><br>    <a href="getline.html">getline</a><br>    <a href="write.html">write</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    seekg  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  istream&amp; seekg( off_type offset, ios::seekdir origin );  istream&amp; seekg( pos_type position );</pre>  <p>The function seekg() is used with input streams, and it  repositions the &quot;get&quot; pointer for the current stream to  <em>offset</em> bytes away from <em>origin</em>, or places the  &quot;get&quot; pointer at <em>position</em>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="seekp.html">seekp</a><br>    <a href="tellg.html">tellg</a><br>    <a href="tellp.html">tellp</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    seekp  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  ostream&amp; seekp( off_type offset, ios::seekdir origin );  ostream&amp; seekp( pos_type position );</pre>  <p>The seekp() function is used with output streams, but is otherwise  very similar to <a href="seekg.html">seekg</a>().</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="seekg.html">seekg</a><br>    <a href="tellg.html">tellg</a><br>    <a href="tellp.html">tellp</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    setf  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  fmtflags setf( fmtflags flags );  fmtflags setf( fmtflags flags, fmtflags needed );</pre>  <p>The function setf() sets the <a href=  "../io_flags.html#format_flags">io stream format flag</a>s of the  current stream to <em>flags</em>. The optional <em>needed</em>  argument specifies that only the flags that are in both  <em>flags</em> and <em>needed</em> should be set. The return value is  the previous configuration of <a href=  "../io_flags.html#format_flags">io stream format flag</a>s.</p>  <p>For example:</p>  <pre class="example-code">   int number = 0x3FF;   cout.setf( ios::dec );   cout &lt;&lt; &quot;Decimal: &quot; &lt;&lt; number &lt;&lt; endl;   cout.unsetf( ios::dec );   cout.setf( ios::hex );   cout &lt;&lt; &quot;Hexadecimal: &quot; &lt;&lt; number &lt;&lt; endl;               </pre>  <p>Note that the preceding code is functionally identical to:</p>  <pre class="example-code">   int number = 0x3FF;   cout &lt;&lt; &quot;Decimal: &quot; &lt;&lt; number &lt;&lt; endl &lt;&lt; hex &lt;&lt; &quot;Hexadecimal: &quot; &lt;&lt; number &lt;&lt; dec &lt;&lt; endl;                </pre>  <p>thanks to <a href="../io_flags.html#manipulators">io stream  manipulator</a>s.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="flags.html">flags</a><br>    <a href="unsetf.html">unsetf</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    sync_with_stdio  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  static bool sync_with_stdio( bool sync=true );</pre>  <p>The sync_with_stdio() function allows you to turn on and off the  ability for the C++ I/O system to work with the C I/O system.</p>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    tellg  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  pos_type tellg();</pre>  <p>The tellg() function is used with input streams, and returns the  current &quot;get&quot; position of the pointer in the stream.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="seekg.html">seekg</a><br>    <a href="seekp.html">seekp</a><br>    <a href="tellp.html">tellp</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    tellp  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  pos_type tellp();</pre>  <p>The tellp() function is used with output streams, and returns the  current &quot;put&quot; position of the pointer in the stream.</p>  <p>For example, the following code displays the file pointer as it  writes to a stream:</p>  <pre class="example-code"> string s(&quot;In Xanadu did Kubla Khan...&quot;); ofstream fout(&quot;output.txt&quot;); for( int i=0; i &lt; s.length(); i++ ) {   cout &lt;&lt; &quot;File pointer: &quot; &lt;&lt; fout.tellp();   fout.put( s[i] );   cout &lt;&lt; &quot; &quot; &lt;&lt; s[i] &lt;&lt; endl; } fout.close();          </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="seekg.html">seekg</a><br>    <a href="seekp.html">seekp</a><br>    <a href="tellg.html">tellg</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    unsetf  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  void unsetf( fmtflags flags );</pre>  <p>The function unsetf() uses <em>flags</em> to clear the <a href=  "../io_flags.html#format_flags">io stream format flag</a>s associated  with the current stream.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="flags.html">flags</a><br>    <a href="setf.html">setf</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    width  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  int width();  int width( int w );</pre>  <p>The function width() returns the current width, which is defined  as the minimum number of characters to display with each output. The  optional argument <em>w</em> can be used to set the width.</p>  <p>For example:</p>  <pre class="example-code">   cout.width( 5 );   cout &lt;&lt; &quot;2&quot;;         </pre>  <p>displays</p>  <pre class="example-code">       2                </pre>  <p>(that&#39;s four spaces followed by a &#39;2&#39;)</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="fill.html">fill</a><br>    <a href="precision.html">precision</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    write  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;fstream&gt;  ostream&amp; write( const char* buffer, streamsize num );</pre>  <p>The write() function is used with output streams, and writes  <em>num</em> bytes from <em>buffer</em> to the current output  stream.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="flush.html">flush</a><br>    <a href="put.html">put</a><br>    <a href="read.html">read</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -